From ssharkins at gmail.com Thu Nov 7 13:37:54 2019 From: ssharkins at gmail.com (Susan Harkins) Date: Thu, 7 Nov 2019 14:37:54 -0500 Subject: [dba-Tech] Word VBA question In-Reply-To: <1567253325.161028209@f509.i.mail.ru> References: <04c501d54bd3$a42ad1f0$ec8075d0$@gmail.com> <1567253325.161028209@f509.i.mail.ru> Message-ID: <07d901d595a2$db092d70$911b8850$@gmail.com> I had to let this go for awhile but I've got it mostly worked out, except for the right loop. This procedure creates a new document with a table for storing each acronym, its, definition, and the page number. Right now, it works fine for the first acronym found, but I can't get the loop correct to keep it going until it's found all of the acronyms. Any help? At this point, don't worry if the definition isn't exact. I haven't been able to test it for a full document -- can't do that until I can get the loop to work. In addition, it's rather ugly code -- I'll clean it up later. Code follows -- and thanks! - Susan H. Sub GetAcronyms() 'Create new document with acronyms, definitions, and page numbers for active document. Dim source As Document Dim target As Document Dim rng As Range Dim tbl As Table Dim strAnronym As String Dim strDefintion As String Dim intAcronym As Integer Dim strRngCopy As String Set source = ActiveDocument Set target = Documents.Add 'Add Table object to target document to organize anacronyms and definitions. With oDoc_Target Set tbl = target.Tables.Add(target.Range, 2, 3) With tbl 'Format the table a bit 'Insert headings .Range.Style = wdStyleNormal .AllowAutoFit = False .Cell(1, 1).Range.Text = "Acronym" .Cell(1, 2).Range.Text = "Definition" .Cell(1, 3).Range.Text = "Page" 'Set row as heading row .Rows(1).HeadingFormat = True .Rows(1).Range.Font.Bold = True .PreferredWidthType = wdPreferredWidthPercent .Columns(1).PreferredWidth = 20 .Columns(2).PreferredWidth = 70 .Columns(3).PreferredWidth = 10 End With End With Set rng = source.Range 'Do While rng.Find.Found With rng.Find 'Use wildcard search to find strings consisting of two or more uppercase letters. .Text = "\(<[A-Z]{2,}>" .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = True .MatchWildcards = True 'Perform the search .Execute strAcronym = Right(rng, Len(rng) - 1) 'Length of strAcronym determines number of words preceding copied. 'Copy acronym definition. intAcronym = Len(strAcronym) rng.Select strDefinition = Selection.MoveLeft(wdWord, intAcronym + 2, True) strDefinition = Selection.Text 'Copy acronym, definition, and page number to target table. With tbl tbl.Select Selection.InsertRowsBelow 1 tbl.Cell(2, 1).Range = strAcronym tbl.Cell(2, 3).Range.Text = rng.Information(wdActiveEndPageNumber) tbl.Cell(2, 2).Range.Text = strDefinition End With End With 'Loop End Sub -----Original Message----- From: dba-Tech On Behalf Of Salakhetdinov Shamil via dba-Tech Sent: Saturday, August 31, 2019 8:09 AM To: Discussion of Hardware and Software issues Cc: Salakhetdinov Shamil Subject: Re: [dba-Tech] Word VBA question Hi Susan -- I'm not sure what method do you use to find the abbreviation - here are two possible solution cases: *** First one *** Sub Macro1() Dim searchWord As String searchWord = "BBB" Dim sel As word.Selection Set sel = word.Application.Selection sel.ClearFormatting With sel.Find .Text = searchWord .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Dim wordFound As Boolean wordFound = sel.Find.Execute If wordFound Then Dim wordLength As Integer wordLength = Strings.Len(searchWord) Dim wdoc As word.Document Set wdoc = word.Application.ActiveDocument Dim wordIndex As Integer wordIndex = GetWordIndex(wdoc, sel.Words.First.Start) If (wordIndex > -1) Then Dim rangeToCopy As word.Range Set rangeToCopy = wdoc.Range(wdoc.Words(wordIndex - wordLength - 1).Start, wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String strToCopy = Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + "'" End If End If End Sub Function GetWordIndex(wdoc As word.Document, wordStartPosition As Integer) As Integer Dim wordIndex As Integer wordFound = False For wordIndex = 1 To wdoc.Words.Count If (wdoc.Words(wordIndex).Start = wordStartPosition) Then GetWordIndex = wordIndex Exit Function End If Next wordIndex GetWordIndex = -1 End Function *** Second one *** Sub Macro2() Dim searchWord As String searchWord = "BBB" Dim wdoc As word.Document Dim wordIndex As Integer Dim wordFound As Boolean Set wdoc = word.Application.ActiveDocument wordFound = False For wordIndex = 1 To wdoc.Words.Count If (wdoc.Words(wordIndex) = searchWord) Then wordFound = True Exit For End If Next wordIndex If wordFound Then Dim wordLength As Integer wordLength = Strings.Len(searchWord) Dim rangeToCopy As word.Range Set rangeToCopy = wdoc.Range(wdoc.Words(wordIndex - wordLength - 1).Start, wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String strToCopy = Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + "'" End If End Sub HTH. -- Shamil P.S. I'm a rare guest here these days - if you have any questions on the subject please e-mail me directly. >Tuesday, August 6, 2019 12:21 AM +03:00 from Susan Harkins : > >Hi everyone! > >I need to copy a range to a new Word document, but it's a complicated >search. When the search pattern find a match, I need to select the >words to the left -- using the length of the match (which can change, >I'm using wildcards). I'm stumped. > >An example: > >The search string matches (BBB) at the text, Better Business Bureau >(BBB). I need to copy the definition of the acronym, to the left of >BBB, and the acronym. The acronym is easy. But I can't figure out for >the life of me how to set a range to "three words to the left of BBB". > >I'd like to avoid using Selection because the editors will be working >with big documents. If that's the only way it can be done, that's the >route I'll go. But I'd rather set a range -- just can' figure out how to do it. > >Thanks! >Susan H. > >_______________________________________________ >dba-Tech mailing list >dba-Tech at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-tech >Website: http://www.databaseadvisors.com -- Salakhetdinov Shamil _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From stuart at lexacorp.com.pg Thu Nov 7 14:06:56 2019 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Fri, 08 Nov 2019 06:06:56 +1000 Subject: [dba-Tech] Word VBA question In-Reply-To: <07d901d595a2$db092d70$911b8850$@gmail.com> References: <04c501d54bd3$a42ad1f0$ec8075d0$@gmail.com>, <1567253325.161028209@f509.i.mail.ru>, <07d901d595a2$db092d70$911b8850$@gmail.com> Message-ID: <5DC47960.16203.8A60370E@stuart.lexacorp.com.pg> The Do... Loop will not execute since rng.Find.Found is false at the start. A classic exampe of the difference between DO WHILE ... LOOP versus DO ..... LOOP WHILE Whaat happens if you move the DO WHILE to after the .Execute and the LOOP before the final END WITH? On 7 Nov 2019 at 14:37, Susan Harkins wrote: > I had to let this go for awhile but I've got it mostly worked out, > except for the right loop. > > This procedure creates a new document with a table for storing each > acronym, its, definition, and the page number. Right now, it works > fine for the first acronym found, but I can't get the loop correct to > keep it going until it's found all of the acronyms. > > Any help? > > At this point, don't worry if the definition isn't exact. I haven't > been able to test it for a full document -- can't do that until I can > get the loop to work. In addition, it's rather ugly code -- I'll clean > it up later. > > Code follows -- and thanks! - Susan H. > > > Sub GetAcronyms() > 'Create new document with acronyms, definitions, and page numbers for > active document. > > Dim source As Document > Dim target As Document > Dim rng As Range > Dim tbl As Table > Dim strAnronym As String > Dim strDefintion As String > Dim intAcronym As Integer > Dim strRngCopy As String > > Set source = ActiveDocument > Set target = Documents.Add > > 'Add Table object to target document to organize anacronyms and > definitions. With oDoc_Target > Set tbl = target.Tables.Add(target.Range, 2, 3) > With tbl > 'Format the table a bit > 'Insert headings > .Range.Style = wdStyleNormal > .AllowAutoFit = False > .Cell(1, 1).Range.Text = "Acronym" > .Cell(1, 2).Range.Text = "Definition" > .Cell(1, 3).Range.Text = "Page" > 'Set row as heading row > .Rows(1).HeadingFormat = True > .Rows(1).Range.Font.Bold = True > .PreferredWidthType = wdPreferredWidthPercent > .Columns(1).PreferredWidth = 20 > .Columns(2).PreferredWidth = 70 > .Columns(3).PreferredWidth = 10 > End With > End With > > Set rng = source.Range > > 'Do While rng.Find.Found > With rng.Find > 'Use wildcard search to find strings consisting of two or more > uppercase > letters. > .Text = "\(<[A-Z]{2,}>" > .Forward = True > .Wrap = wdFindStop > .Format = False > .MatchCase = True > .MatchWildcards = True > 'Perform the search > .Execute > strAcronym = Right(rng, Len(rng) - 1) > 'Length of strAcronym determines number of words preceding > copied. 'Copy acronym definition. intAcronym = Len(strAcronym) > rng.Select strDefinition = Selection.MoveLeft(wdWord, > intAcronym + 2, True) strDefinition = Selection.Text > > 'Copy acronym, definition, and page number to target table. > With tbl > tbl.Select > Selection.InsertRowsBelow 1 > tbl.Cell(2, 1).Range = strAcronym > tbl.Cell(2, 3).Range.Text = > rng.Information(wdActiveEndPageNumber) > tbl.Cell(2, 2).Range.Text = strDefinition > End With > > End With > 'Loop > > End Sub > > > > -----Original Message----- > From: dba-Tech On Behalf Of > Salakhetdinov Shamil via dba-Tech Sent: Saturday, August 31, 2019 8:09 > AM To: Discussion of Hardware and Software issues > Cc: Salakhetdinov Shamil > Subject: Re: [dba-Tech] Word VBA question > > Hi Susan -- > > I'm not sure what method do you use to find the abbreviation - here > are two possible solution cases: > > *** First one *** > > Sub Macro1() > Dim searchWord As String > searchWord = "BBB" > Dim sel As word.Selection > Set sel = word.Application.Selection > sel.ClearFormatting > With sel.Find > .Text = searchWord > .Replacement.Text = "" > .Forward = True > .Wrap = wdFindContinue > .Format = False > .MatchCase = False > .MatchWholeWord = False > .MatchWildcards = False > .MatchSoundsLike = False > .MatchAllWordForms = False > End With > > Dim wordFound As Boolean > wordFound = sel.Find.Execute > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim wdoc As word.Document > Set wdoc = word.Application.ActiveDocument > > Dim wordIndex As Integer > wordIndex = GetWordIndex(wdoc, sel.Words.First.Start) If (wordIndex > > -1) Then Dim rangeToCopy As word.Range Set rangeToCopy = > wdoc.Range(wdoc.Words(wordIndex - wordLength - 1).Start, > wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String strToCopy = > Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + "'" End If End > If End Sub Function GetWordIndex(wdoc As word.Document, > wordStartPosition As Integer) As Integer Dim wordIndex As Integer > wordFound = False For wordIndex = 1 To wdoc.Words.Count If > (wdoc.Words(wordIndex).Start = wordStartPosition) Then GetWordIndex = > wordIndex Exit Function End If Next wordIndex > > GetWordIndex = -1 > End Function > *** Second one *** > > Sub Macro2() > Dim searchWord As String > searchWord = "BBB" > > Dim wdoc As word.Document > Dim wordIndex As Integer > Dim wordFound As Boolean > > Set wdoc = word.Application.ActiveDocument wordFound = False For > wordIndex = 1 To wdoc.Words.Count If (wdoc.Words(wordIndex) = > searchWord) Then wordFound = True Exit For End If Next wordIndex > > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim rangeToCopy As word.Range > Set rangeToCopy = wdoc.Range(wdoc.Words(wordIndex - wordLength - > 1).Start, wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String > strToCopy = Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + > "'" > > End If > End Sub HTH. > > -- Shamil > > P.S. I'm a rare guest here these days - if you have any questions on > the subject please e-mail me directly. > > > >Tuesday, August 6, 2019 12:21 AM +03:00 from Susan Harkins > : > > > >Hi everyone! > > > >I need to copy a range to a new Word document, but it's a complicated > > search. When the search pattern find a match, I need to select the > >words to the left -- using the length of the match (which can change, > > I'm using wildcards). I'm stumped. > > > >An example: > > > >The search string matches (BBB) at the text, Better Business Bureau > >(BBB). I need to copy the definition of the acronym, to the left of > >BBB, and the acronym. The acronym is easy. But I can't figure out for > > the life of me how to set a range to "three words to the left of > >BBB". > > > >I'd like to avoid using Selection because the editors will be working > > with big documents. If that's the only way it can be done, that's > >the route I'll go. But I'd rather set a range -- just can' figure out > >how to do > it. > > > >Thanks! > >Susan H. > > > >_______________________________________________ > >dba-Tech mailing list > >dba-Tech at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-tech > >Website: http://www.databaseadvisors.com > > > -- > Salakhetdinov Shamil > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > From ssharkins at gmail.com Thu Nov 7 14:17:17 2019 From: ssharkins at gmail.com (Susan Harkins) Date: Thu, 7 Nov 2019 15:17:17 -0500 Subject: [dba-Tech] Word VBA question In-Reply-To: <5DC47960.16203.8A60370E@stuart.lexacorp.com.pg> References: <04c501d54bd3$a42ad1f0$ec8075d0$@gmail.com>, <1567253325.161028209@f509.i.mail.ru>, <07d901d595a2$db092d70$911b8850$@gmail.com> <5DC47960.16203.8A60370E@stuart.lexacorp.com.pg> Message-ID: <08a401d595a8$5b10a700$1131f500$@gmail.com> I tried moving it to just after Execute -- that didn't work either. Do While rng.Find doesn't work either. Susan H The Do... Loop will not execute since rng.Find.Found is false at the start. A classic exampe of the difference between DO WHILE ... LOOP versus DO ..... LOOP WHILE Whaat happens if you move the DO WHILE to after the .Execute and the LOOP before the final END WITH? On 7 Nov 2019 at 14:37, Susan Harkins wrote: > I had to let this go for awhile but I've got it mostly worked out, > except for the right loop. > > This procedure creates a new document with a table for storing each > acronym, its, definition, and the page number. Right now, it works > fine for the first acronym found, but I can't get the loop correct to > keep it going until it's found all of the acronyms. > > Any help? > > At this point, don't worry if the definition isn't exact. I haven't > been able to test it for a full document -- can't do that until I can > get the loop to work. In addition, it's rather ugly code -- I'll clean > it up later. > > Code follows -- and thanks! - Susan H. > > > Sub GetAcronyms() > 'Create new document with acronyms, definitions, and page numbers for > active document. > > Dim source As Document > Dim target As Document > Dim rng As Range > Dim tbl As Table > Dim strAnronym As String > Dim strDefintion As String > Dim intAcronym As Integer > Dim strRngCopy As String > > Set source = ActiveDocument > Set target = Documents.Add > > 'Add Table object to target document to organize anacronyms and > definitions. With oDoc_Target > Set tbl = target.Tables.Add(target.Range, 2, 3) > With tbl > 'Format the table a bit > 'Insert headings > .Range.Style = wdStyleNormal > .AllowAutoFit = False > .Cell(1, 1).Range.Text = "Acronym" > .Cell(1, 2).Range.Text = "Definition" > .Cell(1, 3).Range.Text = "Page" > 'Set row as heading row > .Rows(1).HeadingFormat = True > .Rows(1).Range.Font.Bold = True > .PreferredWidthType = wdPreferredWidthPercent > .Columns(1).PreferredWidth = 20 > .Columns(2).PreferredWidth = 70 > .Columns(3).PreferredWidth = 10 > End With > End With > > Set rng = source.Range > > 'Do While rng.Find.Found > With rng.Find > 'Use wildcard search to find strings consisting of two or more > uppercase > letters. > .Text = "\(<[A-Z]{2,}>" > .Forward = True > .Wrap = wdFindStop > .Format = False > .MatchCase = True > .MatchWildcards = True > 'Perform the search > .Execute > strAcronym = Right(rng, Len(rng) - 1) > 'Length of strAcronym determines number of words preceding > copied. 'Copy acronym definition. intAcronym = Len(strAcronym) > rng.Select strDefinition = Selection.MoveLeft(wdWord, > intAcronym + 2, True) strDefinition = Selection.Text > > 'Copy acronym, definition, and page number to target table. > With tbl > tbl.Select > Selection.InsertRowsBelow 1 > tbl.Cell(2, 1).Range = strAcronym > tbl.Cell(2, 3).Range.Text = > rng.Information(wdActiveEndPageNumber) > tbl.Cell(2, 2).Range.Text = strDefinition > End With > > End With > 'Loop > > End Sub > > > > -----Original Message----- > From: dba-Tech On Behalf Of > Salakhetdinov Shamil via dba-Tech Sent: Saturday, August 31, 2019 8:09 > AM To: Discussion of Hardware and Software issues > Cc: Salakhetdinov Shamil > Subject: Re: [dba-Tech] Word VBA question > > Hi Susan -- > > I'm not sure what method do you use to find the abbreviation - here > are two possible solution cases: > > *** First one *** > > Sub Macro1() > Dim searchWord As String > searchWord = "BBB" > Dim sel As word.Selection > Set sel = word.Application.Selection > sel.ClearFormatting > With sel.Find > .Text = searchWord > .Replacement.Text = "" > .Forward = True > .Wrap = wdFindContinue > .Format = False > .MatchCase = False > .MatchWholeWord = False > .MatchWildcards = False > .MatchSoundsLike = False > .MatchAllWordForms = False > End With > > Dim wordFound As Boolean > wordFound = sel.Find.Execute > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim wdoc As word.Document > Set wdoc = word.Application.ActiveDocument > > Dim wordIndex As Integer > wordIndex = GetWordIndex(wdoc, sel.Words.First.Start) If (wordIndex > > -1) Then Dim rangeToCopy As word.Range Set rangeToCopy = > wdoc.Range(wdoc.Words(wordIndex - wordLength - 1).Start, > wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String strToCopy = > Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + "'" End If End > If End Sub Function GetWordIndex(wdoc As word.Document, > wordStartPosition As Integer) As Integer Dim wordIndex As Integer > wordFound = False For wordIndex = 1 To wdoc.Words.Count If > (wdoc.Words(wordIndex).Start = wordStartPosition) Then GetWordIndex = > wordIndex Exit Function End If Next wordIndex > > GetWordIndex = -1 > End Function > *** Second one *** > > Sub Macro2() > Dim searchWord As String > searchWord = "BBB" > > Dim wdoc As word.Document > Dim wordIndex As Integer > Dim wordFound As Boolean > > Set wdoc = word.Application.ActiveDocument wordFound = False For > wordIndex = 1 To wdoc.Words.Count If (wdoc.Words(wordIndex) = > searchWord) Then wordFound = True Exit For End If Next wordIndex > > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim rangeToCopy As word.Range > Set rangeToCopy = wdoc.Range(wdoc.Words(wordIndex - wordLength - > 1).Start, wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String > strToCopy = Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + > "'" > > End If > End Sub HTH. > > -- Shamil > > P.S. I'm a rare guest here these days - if you have any questions on > the subject please e-mail me directly. > > > >Tuesday, August 6, 2019 12:21 AM +03:00 from Susan Harkins > : > > > >Hi everyone! > > > >I need to copy a range to a new Word document, but it's a complicated > > search. When the search pattern find a match, I need to select the > >words to the left -- using the length of the match (which can change, > > I'm using wildcards). I'm stumped. > > > >An example: > > > >The search string matches (BBB) at the text, Better Business Bureau > >(BBB). I need to copy the definition of the acronym, to the left of > >BBB, and the acronym. The acronym is easy. But I can't figure out for > > the life of me how to set a range to "three words to the left of > >BBB". > > > >I'd like to avoid using Selection because the editors will be working > > with big documents. If that's the only way it can be done, that's > >the route I'll go. But I'd rather set a range -- just can' figure out > >how to do > it. > > > >Thanks! > >Susan H. > > > >_______________________________________________ > >dba-Tech mailing list > >dba-Tech at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-tech > >Website: http://www.databaseadvisors.com > > > -- > Salakhetdinov Shamil > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From ssharkins at gmail.com Thu Nov 7 14:41:06 2019 From: ssharkins at gmail.com (Susan Harkins) Date: Thu, 7 Nov 2019 15:41:06 -0500 Subject: [dba-Tech] FW: Word VBA question In-Reply-To: <08b501d595ab$a3290b60$e97b2220$@gmail.com> References: <04c501d54bd3$a42ad1f0$ec8075d0$@gmail.com>, <1567253325.161028209@f509.i.mail.ru>, <07d901d595a2$db092d70$911b8850$@gmail.com> <5DC47960.16203.8A60370E@stuart.lexacorp.com.pg> <08b501d595ab$a3290b60$e97b2220$@gmail.com> Message-ID: <08b701d595ab$ae35df10$0aa19d30$@gmail.com> Moving the loop seemed to iterate correctly -- but nothing was entered in the new document -- so although it didn't work, that is a nice clue. Susan H. I tried moving it to just after Execute -- that didn't work either. Do While rng.Find doesn't work either. Susan H The Do... Loop will not execute since rng.Find.Found is false at the start. A classic exampe of the difference between DO WHILE ... LOOP versus DO ..... LOOP WHILE Whaat happens if you move the DO WHILE to after the .Execute and the LOOP before the final END WITH? On 7 Nov 2019 at 14:37, Susan Harkins wrote: > I had to let this go for awhile but I've got it mostly worked out, > except for the right loop. > > This procedure creates a new document with a table for storing each > acronym, its, definition, and the page number. Right now, it works > fine for the first acronym found, but I can't get the loop correct to > keep it going until it's found all of the acronyms. > > Any help? > > At this point, don't worry if the definition isn't exact. I haven't > been able to test it for a full document -- can't do that until I can > get the loop to work. In addition, it's rather ugly code -- I'll clean > it up later. > > Code follows -- and thanks! - Susan H. > > > Sub GetAcronyms() > 'Create new document with acronyms, definitions, and page numbers for > active document. > > Dim source As Document > Dim target As Document > Dim rng As Range > Dim tbl As Table > Dim strAnronym As String > Dim strDefintion As String > Dim intAcronym As Integer > Dim strRngCopy As String > > Set source = ActiveDocument > Set target = Documents.Add > > 'Add Table object to target document to organize anacronyms and > definitions. With oDoc_Target > Set tbl = target.Tables.Add(target.Range, 2, 3) > With tbl > 'Format the table a bit > 'Insert headings > .Range.Style = wdStyleNormal > .AllowAutoFit = False > .Cell(1, 1).Range.Text = "Acronym" > .Cell(1, 2).Range.Text = "Definition" > .Cell(1, 3).Range.Text = "Page" > 'Set row as heading row > .Rows(1).HeadingFormat = True > .Rows(1).Range.Font.Bold = True > .PreferredWidthType = wdPreferredWidthPercent > .Columns(1).PreferredWidth = 20 > .Columns(2).PreferredWidth = 70 > .Columns(3).PreferredWidth = 10 > End With > End With > > Set rng = source.Range > > 'Do While rng.Find.Found > With rng.Find > 'Use wildcard search to find strings consisting of two or more > uppercase > letters. > .Text = "\(<[A-Z]{2,}>" > .Forward = True > .Wrap = wdFindStop > .Format = False > .MatchCase = True > .MatchWildcards = True > 'Perform the search > .Execute > strAcronym = Right(rng, Len(rng) - 1) > 'Length of strAcronym determines number of words preceding > copied. 'Copy acronym definition. intAcronym = Len(strAcronym) > rng.Select strDefinition = Selection.MoveLeft(wdWord, > intAcronym + 2, True) strDefinition = Selection.Text > > 'Copy acronym, definition, and page number to target table. > With tbl > tbl.Select > Selection.InsertRowsBelow 1 > tbl.Cell(2, 1).Range = strAcronym > tbl.Cell(2, 3).Range.Text = > rng.Information(wdActiveEndPageNumber) > tbl.Cell(2, 2).Range.Text = strDefinition > End With > > End With > 'Loop > > End Sub > > > > -----Original Message----- > From: dba-Tech On Behalf Of > Salakhetdinov Shamil via dba-Tech Sent: Saturday, August 31, 2019 8:09 > AM To: Discussion of Hardware and Software issues > Cc: Salakhetdinov Shamil > Subject: Re: [dba-Tech] Word VBA question > > Hi Susan -- > > I'm not sure what method do you use to find the abbreviation - here > are two possible solution cases: > > *** First one *** > > Sub Macro1() > Dim searchWord As String > searchWord = "BBB" > Dim sel As word.Selection > Set sel = word.Application.Selection > sel.ClearFormatting > With sel.Find > .Text = searchWord > .Replacement.Text = "" > .Forward = True > .Wrap = wdFindContinue > .Format = False > .MatchCase = False > .MatchWholeWord = False > .MatchWildcards = False > .MatchSoundsLike = False > .MatchAllWordForms = False > End With > > Dim wordFound As Boolean > wordFound = sel.Find.Execute > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim wdoc As word.Document > Set wdoc = word.Application.ActiveDocument > > Dim wordIndex As Integer > wordIndex = GetWordIndex(wdoc, sel.Words.First.Start) If (wordIndex > > -1) Then Dim rangeToCopy As word.Range Set rangeToCopy = > wdoc.Range(wdoc.Words(wordIndex - wordLength - 1).Start, > wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String strToCopy = > Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + "'" End If End > If End Sub Function GetWordIndex(wdoc As word.Document, > wordStartPosition As Integer) As Integer Dim wordIndex As Integer > wordFound = False For wordIndex = 1 To wdoc.Words.Count If > (wdoc.Words(wordIndex).Start = wordStartPosition) Then GetWordIndex = > wordIndex Exit Function End If Next wordIndex > > GetWordIndex = -1 > End Function > *** Second one *** > > Sub Macro2() > Dim searchWord As String > searchWord = "BBB" > > Dim wdoc As word.Document > Dim wordIndex As Integer > Dim wordFound As Boolean > > Set wdoc = word.Application.ActiveDocument wordFound = False For > wordIndex = 1 To wdoc.Words.Count If (wdoc.Words(wordIndex) = > searchWord) Then wordFound = True Exit For End If Next wordIndex > > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim rangeToCopy As word.Range > Set rangeToCopy = wdoc.Range(wdoc.Words(wordIndex - wordLength - > 1).Start, wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String > strToCopy = Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + > "'" > > End If > End Sub HTH. > > -- Shamil > > P.S. I'm a rare guest here these days - if you have any questions on > the subject please e-mail me directly. > > > >Tuesday, August 6, 2019 12:21 AM +03:00 from Susan Harkins > : > > > >Hi everyone! > > > >I need to copy a range to a new Word document, but it's a complicated > >search. When the search pattern find a match, I need to select the > >words to the left -- using the length of the match (which can change, > >I'm using wildcards). I'm stumped. > > > >An example: > > > >The search string matches (BBB) at the text, Better Business Bureau > >(BBB). I need to copy the definition of the acronym, to the left of > >BBB, and the acronym. The acronym is easy. But I can't figure out for > >the life of me how to set a range to "three words to the left of > >BBB". > > > >I'd like to avoid using Selection because the editors will be working > >with big documents. If that's the only way it can be done, that's the > >route I'll go. But I'd rather set a range -- just can' figure out how > >to do > it. > > > >Thanks! > >Susan H. > > > >_______________________________________________ > >dba-Tech mailing list > >dba-Tech at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-tech > >Website: http://www.databaseadvisors.com > > > -- > Salakhetdinov Shamil > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From accessd at shaw.ca Thu Nov 7 21:32:24 2019 From: accessd at shaw.ca (Jim Lawrence) Date: Thu, 7 Nov 2019 20:32:24 -0700 (MST) Subject: [dba-Tech] Word VBA question In-Reply-To: <08a401d595a8$5b10a700$1131f500$@gmail.com> References: <04c501d54bd3$a42ad1f0$ec8075d0$@gmail.com> <1567253325.161028209@f509.i.mail.ru> <07d901d595a2$db092d70$911b8850$@gmail.com> <5DC47960.16203.8A60370E@stuart.lexacorp.com.pg> <08a401d595a8$5b10a700$1131f500$@gmail.com> Message-ID: <1540252361.581913851.1573183944763.JavaMail.zimbra@shaw.ca> Hi Susan: I know nothing (very little) about working with documents but when using a do..while or for-next loop, getting the count value is most important. States can change, in some cases for no apparent reason. A fixed value will not. If there is a problem with getting an appropriate response that is where I would start looking. Jim ----- Original Message ----- From: "Susan Harkins" To: "Discussion of Hardware and Software issues" Sent: Thursday, November 7, 2019 12:17:17 PM Subject: Re: [dba-Tech] Word VBA question I tried moving it to just after Execute -- that didn't work either. Do While rng.Find doesn't work either. Susan H The Do... Loop will not execute since rng.Find.Found is false at the start. A classic exampe of the difference between DO WHILE ... LOOP versus DO ..... LOOP WHILE Whaat happens if you move the DO WHILE to after the .Execute and the LOOP before the final END WITH? On 7 Nov 2019 at 14:37, Susan Harkins wrote: > I had to let this go for awhile but I've got it mostly worked out, > except for the right loop. > > This procedure creates a new document with a table for storing each > acronym, its, definition, and the page number. Right now, it works > fine for the first acronym found, but I can't get the loop correct to > keep it going until it's found all of the acronyms. > > Any help? > > At this point, don't worry if the definition isn't exact. I haven't > been able to test it for a full document -- can't do that until I can > get the loop to work. In addition, it's rather ugly code -- I'll clean > it up later. > > Code follows -- and thanks! - Susan H. > > > Sub GetAcronyms() > 'Create new document with acronyms, definitions, and page numbers for > active document. > > Dim source As Document > Dim target As Document > Dim rng As Range > Dim tbl As Table > Dim strAnronym As String > Dim strDefintion As String > Dim intAcronym As Integer > Dim strRngCopy As String > > Set source = ActiveDocument > Set target = Documents.Add > > 'Add Table object to target document to organize anacronyms and > definitions. With oDoc_Target > Set tbl = target.Tables.Add(target.Range, 2, 3) > With tbl > 'Format the table a bit > 'Insert headings > .Range.Style = wdStyleNormal > .AllowAutoFit = False > .Cell(1, 1).Range.Text = "Acronym" > .Cell(1, 2).Range.Text = "Definition" > .Cell(1, 3).Range.Text = "Page" > 'Set row as heading row > .Rows(1).HeadingFormat = True > .Rows(1).Range.Font.Bold = True > .PreferredWidthType = wdPreferredWidthPercent > .Columns(1).PreferredWidth = 20 > .Columns(2).PreferredWidth = 70 > .Columns(3).PreferredWidth = 10 > End With > End With > > Set rng = source.Range > > 'Do While rng.Find.Found > With rng.Find > 'Use wildcard search to find strings consisting of two or more > uppercase > letters. > .Text = "\(<[A-Z]{2,}>" > .Forward = True > .Wrap = wdFindStop > .Format = False > .MatchCase = True > .MatchWildcards = True > 'Perform the search > .Execute > strAcronym = Right(rng, Len(rng) - 1) > 'Length of strAcronym determines number of words preceding > copied. 'Copy acronym definition. intAcronym = Len(strAcronym) > rng.Select strDefinition = Selection.MoveLeft(wdWord, > intAcronym + 2, True) strDefinition = Selection.Text > > 'Copy acronym, definition, and page number to target table. > With tbl > tbl.Select > Selection.InsertRowsBelow 1 > tbl.Cell(2, 1).Range = strAcronym > tbl.Cell(2, 3).Range.Text = > rng.Information(wdActiveEndPageNumber) > tbl.Cell(2, 2).Range.Text = strDefinition > End With > > End With > 'Loop > > End Sub > > > > -----Original Message----- > From: dba-Tech On Behalf Of > Salakhetdinov Shamil via dba-Tech Sent: Saturday, August 31, 2019 8:09 > AM To: Discussion of Hardware and Software issues > Cc: Salakhetdinov Shamil > Subject: Re: [dba-Tech] Word VBA question > > Hi Susan -- > > I'm not sure what method do you use to find the abbreviation - here > are two possible solution cases: > > *** First one *** > > Sub Macro1() > Dim searchWord As String > searchWord = "BBB" > Dim sel As word.Selection > Set sel = word.Application.Selection > sel.ClearFormatting > With sel.Find > .Text = searchWord > .Replacement.Text = "" > .Forward = True > .Wrap = wdFindContinue > .Format = False > .MatchCase = False > .MatchWholeWord = False > .MatchWildcards = False > .MatchSoundsLike = False > .MatchAllWordForms = False > End With > > Dim wordFound As Boolean > wordFound = sel.Find.Execute > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim wdoc As word.Document > Set wdoc = word.Application.ActiveDocument > > Dim wordIndex As Integer > wordIndex = GetWordIndex(wdoc, sel.Words.First.Start) If (wordIndex > > -1) Then Dim rangeToCopy As word.Range Set rangeToCopy = > wdoc.Range(wdoc.Words(wordIndex - wordLength - 1).Start, > wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String strToCopy = > Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + "'" End If End > If End Sub Function GetWordIndex(wdoc As word.Document, > wordStartPosition As Integer) As Integer Dim wordIndex As Integer > wordFound = False For wordIndex = 1 To wdoc.Words.Count If > (wdoc.Words(wordIndex).Start = wordStartPosition) Then GetWordIndex = > wordIndex Exit Function End If Next wordIndex > > GetWordIndex = -1 > End Function > *** Second one *** > > Sub Macro2() > Dim searchWord As String > searchWord = "BBB" > > Dim wdoc As word.Document > Dim wordIndex As Integer > Dim wordFound As Boolean > > Set wdoc = word.Application.ActiveDocument wordFound = False For > wordIndex = 1 To wdoc.Words.Count If (wdoc.Words(wordIndex) = > searchWord) Then wordFound = True Exit For End If Next wordIndex > > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim rangeToCopy As word.Range > Set rangeToCopy = wdoc.Range(wdoc.Words(wordIndex - wordLength - > 1).Start, wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String > strToCopy = Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + > "'" > > End If > End Sub HTH. > > -- Shamil > > P.S. I'm a rare guest here these days - if you have any questions on > the subject please e-mail me directly. > > > >Tuesday, August 6, 2019 12:21 AM +03:00 from Susan Harkins > : > > > >Hi everyone! > > > >I need to copy a range to a new Word document, but it's a complicated > > search. When the search pattern find a match, I need to select the > >words to the left -- using the length of the match (which can change, > > I'm using wildcards). I'm stumped. > > > >An example: > > > >The search string matches (BBB) at the text, Better Business Bureau > >(BBB). I need to copy the definition of the acronym, to the left of > >BBB, and the acronym. The acronym is easy. But I can't figure out for > > the life of me how to set a range to "three words to the left of > >BBB". > > > >I'd like to avoid using Selection because the editors will be working > > with big documents. If that's the only way it can be done, that's > >the route I'll go. But I'd rather set a range -- just can' figure out > >how to do > it. > > > >Thanks! > >Susan H. > > > >_______________________________________________ > >dba-Tech mailing list > >dba-Tech at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-tech > >Website: http://www.databaseadvisors.com > > > -- > Salakhetdinov Shamil > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From ssharkins at gmail.com Fri Nov 8 08:17:10 2019 From: ssharkins at gmail.com (Susan Harkins) Date: Fri, 8 Nov 2019 09:17:10 -0500 Subject: [dba-Tech] Word VBA question In-Reply-To: <1540252361.581913851.1573183944763.JavaMail.zimbra@shaw.ca> References: <04c501d54bd3$a42ad1f0$ec8075d0$@gmail.com> <1567253325.161028209@f509.i.mail.ru> <07d901d595a2$db092d70$911b8850$@gmail.com> <5DC47960.16203.8A60370E@stuart.lexacorp.com.pg> <08a401d595a8$5b10a700$1131f500$@gmail.com> <1540252361.581913851.1573183944763.JavaMail.zimbra@shaw.ca> Message-ID: <012601d5963f$37b1e890$a715b9b0$@gmail.com> There's no count with a Do While loop -- the loop continues as long as the condition is true. As Stuart pointed out my loop is always false because the search string hasn't been found yet. It works after the Execute method, but the values aren't copied to the new document. Susan H. Hi Susan: I know nothing (very little) about working with documents but when using a do..while or for-next loop, getting the count value is most important. States can change, in some cases for no apparent reason. A fixed value will not. If there is a problem with getting an appropriate response that is where I would start looking. Jim ----- Original Message ----- From: "Susan Harkins" To: "Discussion of Hardware and Software issues" Sent: Thursday, November 7, 2019 12:17:17 PM Subject: Re: [dba-Tech] Word VBA question I tried moving it to just after Execute -- that didn't work either. Do While rng.Find doesn't work either. Susan H The Do... Loop will not execute since rng.Find.Found is false at the start. A classic exampe of the difference between DO WHILE ... LOOP versus DO ..... LOOP WHILE Whaat happens if you move the DO WHILE to after the .Execute and the LOOP before the final END WITH? On 7 Nov 2019 at 14:37, Susan Harkins wrote: > I had to let this go for awhile but I've got it mostly worked out, > except for the right loop. > > This procedure creates a new document with a table for storing each > acronym, its, definition, and the page number. Right now, it works > fine for the first acronym found, but I can't get the loop correct to > keep it going until it's found all of the acronyms. > > Any help? > > At this point, don't worry if the definition isn't exact. I haven't > been able to test it for a full document -- can't do that until I can > get the loop to work. In addition, it's rather ugly code -- I'll clean > it up later. > > Code follows -- and thanks! - Susan H. > > > Sub GetAcronyms() > 'Create new document with acronyms, definitions, and page numbers for > active document. > > Dim source As Document > Dim target As Document > Dim rng As Range > Dim tbl As Table > Dim strAnronym As String > Dim strDefintion As String > Dim intAcronym As Integer > Dim strRngCopy As String > > Set source = ActiveDocument > Set target = Documents.Add > > 'Add Table object to target document to organize anacronyms and > definitions. With oDoc_Target > Set tbl = target.Tables.Add(target.Range, 2, 3) > With tbl > 'Format the table a bit > 'Insert headings > .Range.Style = wdStyleNormal > .AllowAutoFit = False > .Cell(1, 1).Range.Text = "Acronym" > .Cell(1, 2).Range.Text = "Definition" > .Cell(1, 3).Range.Text = "Page" > 'Set row as heading row > .Rows(1).HeadingFormat = True > .Rows(1).Range.Font.Bold = True > .PreferredWidthType = wdPreferredWidthPercent > .Columns(1).PreferredWidth = 20 > .Columns(2).PreferredWidth = 70 > .Columns(3).PreferredWidth = 10 > End With > End With > > Set rng = source.Range > > 'Do While rng.Find.Found > With rng.Find > 'Use wildcard search to find strings consisting of two or more > uppercase > letters. > .Text = "\(<[A-Z]{2,}>" > .Forward = True > .Wrap = wdFindStop > .Format = False > .MatchCase = True > .MatchWildcards = True > 'Perform the search > .Execute > strAcronym = Right(rng, Len(rng) - 1) > 'Length of strAcronym determines number of words preceding > copied. 'Copy acronym definition. intAcronym = Len(strAcronym) > rng.Select strDefinition = Selection.MoveLeft(wdWord, > intAcronym + 2, True) strDefinition = Selection.Text > > 'Copy acronym, definition, and page number to target table. > With tbl > tbl.Select > Selection.InsertRowsBelow 1 > tbl.Cell(2, 1).Range = strAcronym > tbl.Cell(2, 3).Range.Text = > rng.Information(wdActiveEndPageNumber) > tbl.Cell(2, 2).Range.Text = strDefinition > End With > > End With > 'Loop > > End Sub > > > > -----Original Message----- > From: dba-Tech On Behalf Of > Salakhetdinov Shamil via dba-Tech Sent: Saturday, August 31, 2019 8:09 > AM To: Discussion of Hardware and Software issues > Cc: Salakhetdinov Shamil > Subject: Re: [dba-Tech] Word VBA question > > Hi Susan -- > > I'm not sure what method do you use to find the abbreviation - here > are two possible solution cases: > > *** First one *** > > Sub Macro1() > Dim searchWord As String > searchWord = "BBB" > Dim sel As word.Selection > Set sel = word.Application.Selection > sel.ClearFormatting > With sel.Find > .Text = searchWord > .Replacement.Text = "" > .Forward = True > .Wrap = wdFindContinue > .Format = False > .MatchCase = False > .MatchWholeWord = False > .MatchWildcards = False > .MatchSoundsLike = False > .MatchAllWordForms = False > End With > > Dim wordFound As Boolean > wordFound = sel.Find.Execute > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim wdoc As word.Document > Set wdoc = word.Application.ActiveDocument > > Dim wordIndex As Integer > wordIndex = GetWordIndex(wdoc, sel.Words.First.Start) If (wordIndex > > -1) Then Dim rangeToCopy As word.Range Set rangeToCopy = > wdoc.Range(wdoc.Words(wordIndex - wordLength - 1).Start, > wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String strToCopy = > Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + "'" End If End > If End Sub Function GetWordIndex(wdoc As word.Document, > wordStartPosition As Integer) As Integer Dim wordIndex As Integer > wordFound = False For wordIndex = 1 To wdoc.Words.Count If > (wdoc.Words(wordIndex).Start = wordStartPosition) Then GetWordIndex = > wordIndex Exit Function End If Next wordIndex > > GetWordIndex = -1 > End Function > *** Second one *** > > Sub Macro2() > Dim searchWord As String > searchWord = "BBB" > > Dim wdoc As word.Document > Dim wordIndex As Integer > Dim wordFound As Boolean > > Set wdoc = word.Application.ActiveDocument wordFound = False For > wordIndex = 1 To wdoc.Words.Count If (wdoc.Words(wordIndex) = > searchWord) Then wordFound = True Exit For End If Next wordIndex > > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim rangeToCopy As word.Range > Set rangeToCopy = wdoc.Range(wdoc.Words(wordIndex - wordLength - > 1).Start, wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String > strToCopy = Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + > "'" > > End If > End Sub HTH. > > -- Shamil > > P.S. I'm a rare guest here these days - if you have any questions on > the subject please e-mail me directly. > > > >Tuesday, August 6, 2019 12:21 AM +03:00 from Susan Harkins > : > > > >Hi everyone! > > > >I need to copy a range to a new Word document, but it's a complicated > >search. When the search pattern find a match, I need to select the > >words to the left -- using the length of the match (which can change, > >I'm using wildcards). I'm stumped. > > > >An example: > > > >The search string matches (BBB) at the text, Better Business Bureau > >(BBB). I need to copy the definition of the acronym, to the left of > >BBB, and the acronym. The acronym is easy. But I can't figure out for > >the life of me how to set a range to "three words to the left of > >BBB". > > > >I'd like to avoid using Selection because the editors will be working > >with big documents. If that's the only way it can be done, that's the > >route I'll go. But I'd rather set a range -- just can' figure out how > >to do > it. > > > >Thanks! > >Susan H. > > > >_______________________________________________ > >dba-Tech mailing list > >dba-Tech at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-tech > >Website: http://www.databaseadvisors.com > > > -- > Salakhetdinov Shamil > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From accessd at shaw.ca Fri Nov 8 19:23:24 2019 From: accessd at shaw.ca (Jim Lawrence) Date: Fri, 8 Nov 2019 18:23:24 -0700 (MST) Subject: [dba-Tech] Word VBA question In-Reply-To: <012601d5963f$37b1e890$a715b9b0$@gmail.com> References: <04c501d54bd3$a42ad1f0$ec8075d0$@gmail.com> <1567253325.161028209@f509.i.mail.ru> <07d901d595a2$db092d70$911b8850$@gmail.com> <5DC47960.16203.8A60370E@stuart.lexacorp.com.pg> <08a401d595a8$5b10a700$1131f500$@gmail.com> <1540252361.581913851.1573183944763.JavaMail.zimbra@shaw.ca> <012601d5963f$37b1e890$a715b9b0$@gmail.com> Message-ID: <2077710002.587209823.1573262604962.JavaMail.zimbra@shaw.ca> Hi Susan: Is that false condition what you are expecting? Jim ----- Original Message ----- From: "Susan Harkins" To: "Discussion of Hardware and Software issues" Sent: Friday, November 8, 2019 6:17:10 AM Subject: Re: [dba-Tech] Word VBA question There's no count with a Do While loop -- the loop continues as long as the condition is true. As Stuart pointed out my loop is always false because the search string hasn't been found yet. It works after the Execute method, but the values aren't copied to the new document. Susan H. Hi Susan: I know nothing (very little) about working with documents but when using a do..while or for-next loop, getting the count value is most important. States can change, in some cases for no apparent reason. A fixed value will not. If there is a problem with getting an appropriate response that is where I would start looking. Jim ----- Original Message ----- From: "Susan Harkins" To: "Discussion of Hardware and Software issues" Sent: Thursday, November 7, 2019 12:17:17 PM Subject: Re: [dba-Tech] Word VBA question I tried moving it to just after Execute -- that didn't work either. Do While rng.Find doesn't work either. Susan H The Do... Loop will not execute since rng.Find.Found is false at the start. A classic exampe of the difference between DO WHILE ... LOOP versus DO ..... LOOP WHILE Whaat happens if you move the DO WHILE to after the .Execute and the LOOP before the final END WITH? On 7 Nov 2019 at 14:37, Susan Harkins wrote: > I had to let this go for awhile but I've got it mostly worked out, > except for the right loop. > > This procedure creates a new document with a table for storing each > acronym, its, definition, and the page number. Right now, it works > fine for the first acronym found, but I can't get the loop correct to > keep it going until it's found all of the acronyms. > > Any help? > > At this point, don't worry if the definition isn't exact. I haven't > been able to test it for a full document -- can't do that until I can > get the loop to work. In addition, it's rather ugly code -- I'll clean > it up later. > > Code follows -- and thanks! - Susan H. > > > Sub GetAcronyms() > 'Create new document with acronyms, definitions, and page numbers for > active document. > > Dim source As Document > Dim target As Document > Dim rng As Range > Dim tbl As Table > Dim strAnronym As String > Dim strDefintion As String > Dim intAcronym As Integer > Dim strRngCopy As String > > Set source = ActiveDocument > Set target = Documents.Add > > 'Add Table object to target document to organize anacronyms and > definitions. With oDoc_Target > Set tbl = target.Tables.Add(target.Range, 2, 3) > With tbl > 'Format the table a bit > 'Insert headings > .Range.Style = wdStyleNormal > .AllowAutoFit = False > .Cell(1, 1).Range.Text = "Acronym" > .Cell(1, 2).Range.Text = "Definition" > .Cell(1, 3).Range.Text = "Page" > 'Set row as heading row > .Rows(1).HeadingFormat = True > .Rows(1).Range.Font.Bold = True > .PreferredWidthType = wdPreferredWidthPercent > .Columns(1).PreferredWidth = 20 > .Columns(2).PreferredWidth = 70 > .Columns(3).PreferredWidth = 10 > End With > End With > > Set rng = source.Range > > 'Do While rng.Find.Found > With rng.Find > 'Use wildcard search to find strings consisting of two or more > uppercase > letters. > .Text = "\(<[A-Z]{2,}>" > .Forward = True > .Wrap = wdFindStop > .Format = False > .MatchCase = True > .MatchWildcards = True > 'Perform the search > .Execute > strAcronym = Right(rng, Len(rng) - 1) > 'Length of strAcronym determines number of words preceding > copied. 'Copy acronym definition. intAcronym = Len(strAcronym) > rng.Select strDefinition = Selection.MoveLeft(wdWord, > intAcronym + 2, True) strDefinition = Selection.Text > > 'Copy acronym, definition, and page number to target table. > With tbl > tbl.Select > Selection.InsertRowsBelow 1 > tbl.Cell(2, 1).Range = strAcronym > tbl.Cell(2, 3).Range.Text = > rng.Information(wdActiveEndPageNumber) > tbl.Cell(2, 2).Range.Text = strDefinition > End With > > End With > 'Loop > > End Sub > > > > -----Original Message----- > From: dba-Tech On Behalf Of > Salakhetdinov Shamil via dba-Tech Sent: Saturday, August 31, 2019 8:09 > AM To: Discussion of Hardware and Software issues > Cc: Salakhetdinov Shamil > Subject: Re: [dba-Tech] Word VBA question > > Hi Susan -- > > I'm not sure what method do you use to find the abbreviation - here > are two possible solution cases: > > *** First one *** > > Sub Macro1() > Dim searchWord As String > searchWord = "BBB" > Dim sel As word.Selection > Set sel = word.Application.Selection > sel.ClearFormatting > With sel.Find > .Text = searchWord > .Replacement.Text = "" > .Forward = True > .Wrap = wdFindContinue > .Format = False > .MatchCase = False > .MatchWholeWord = False > .MatchWildcards = False > .MatchSoundsLike = False > .MatchAllWordForms = False > End With > > Dim wordFound As Boolean > wordFound = sel.Find.Execute > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim wdoc As word.Document > Set wdoc = word.Application.ActiveDocument > > Dim wordIndex As Integer > wordIndex = GetWordIndex(wdoc, sel.Words.First.Start) If (wordIndex > > -1) Then Dim rangeToCopy As word.Range Set rangeToCopy = > wdoc.Range(wdoc.Words(wordIndex - wordLength - 1).Start, > wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String strToCopy = > Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + "'" End If End > If End Sub Function GetWordIndex(wdoc As word.Document, > wordStartPosition As Integer) As Integer Dim wordIndex As Integer > wordFound = False For wordIndex = 1 To wdoc.Words.Count If > (wdoc.Words(wordIndex).Start = wordStartPosition) Then GetWordIndex = > wordIndex Exit Function End If Next wordIndex > > GetWordIndex = -1 > End Function > *** Second one *** > > Sub Macro2() > Dim searchWord As String > searchWord = "BBB" > > Dim wdoc As word.Document > Dim wordIndex As Integer > Dim wordFound As Boolean > > Set wdoc = word.Application.ActiveDocument wordFound = False For > wordIndex = 1 To wdoc.Words.Count If (wdoc.Words(wordIndex) = > searchWord) Then wordFound = True Exit For End If Next wordIndex > > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim rangeToCopy As word.Range > Set rangeToCopy = wdoc.Range(wdoc.Words(wordIndex - wordLength - > 1).Start, wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String > strToCopy = Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + > "'" > > End If > End Sub HTH. > > -- Shamil > > P.S. I'm a rare guest here these days - if you have any questions on > the subject please e-mail me directly. > > > >Tuesday, August 6, 2019 12:21 AM +03:00 from Susan Harkins > : > > > >Hi everyone! > > > >I need to copy a range to a new Word document, but it's a complicated > >search. When the search pattern find a match, I need to select the > >words to the left -- using the length of the match (which can change, > >I'm using wildcards). I'm stumped. > > > >An example: > > > >The search string matches (BBB) at the text, Better Business Bureau > >(BBB). I need to copy the definition of the acronym, to the left of > >BBB, and the acronym. The acronym is easy. But I can't figure out for > >the life of me how to set a range to "three words to the left of > >BBB". > > > >I'd like to avoid using Selection because the editors will be working > >with big documents. If that's the only way it can be done, that's the > >route I'll go. But I'd rather set a range -- just can' figure out how > >to do > it. > > > >Thanks! > >Susan H. > > > >_______________________________________________ > >dba-Tech mailing list > >dba-Tech at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-tech > >Website: http://www.databaseadvisors.com > > > -- > Salakhetdinov Shamil > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From ssharkins at gmail.com Sat Nov 9 05:09:28 2019 From: ssharkins at gmail.com (Susan Harkins) Date: Sat, 9 Nov 2019 06:09:28 -0500 Subject: [dba-Tech] Word VBA question In-Reply-To: <2077710002.587209823.1573262604962.JavaMail.zimbra@shaw.ca> References: <04c501d54bd3$a42ad1f0$ec8075d0$@gmail.com> <1567253325.161028209@f509.i.mail.ru> <07d901d595a2$db092d70$911b8850$@gmail.com> <5DC47960.16203.8A60370E@stuart.lexacorp.com.pg> <08a401d595a8$5b10a700$1131f500$@gmail.com> <1540252361.581913851.1573183944763.JavaMail.zimbra@shaw.ca> <012601d5963f$37b1e890$a715b9b0$@gmail.com> <2077710002.587209823.1573262604962.JavaMail.zimbra@shaw.ca> Message-ID: <003301d596ee$29b5f0b0$7d21d210$@gmail.com> Yes; before the find is triggered, .Found is false -- nothing has been found. When I move the loop after .Execute, the loop iterates, but it doesn't add the found strings to the new document. When there's no loop, everything works as expected one time -- it finds and copies the strings to the new document once. The documents will have been strings to copy. Susan H. -----Original Message----- From: dba-Tech On Behalf Of Jim Lawrence Sent: Friday, November 8, 2019 8:23 PM To: Discussion of Hardware and Software issues Subject: Re: [dba-Tech] Word VBA question Hi Susan: Is that false condition what you are expecting? Jim ----- Original Message ----- From: "Susan Harkins" To: "Discussion of Hardware and Software issues" Sent: Friday, November 8, 2019 6:17:10 AM Subject: Re: [dba-Tech] Word VBA question There's no count with a Do While loop -- the loop continues as long as the condition is true. As Stuart pointed out my loop is always false because the search string hasn't been found yet. It works after the Execute method, but the values aren't copied to the new document. Susan H. Hi Susan: I know nothing (very little) about working with documents but when using a do..while or for-next loop, getting the count value is most important. States can change, in some cases for no apparent reason. A fixed value will not. If there is a problem with getting an appropriate response that is where I would start looking. Jim ----- Original Message ----- From: "Susan Harkins" To: "Discussion of Hardware and Software issues" Sent: Thursday, November 7, 2019 12:17:17 PM Subject: Re: [dba-Tech] Word VBA question I tried moving it to just after Execute -- that didn't work either. Do While rng.Find doesn't work either. Susan H The Do... Loop will not execute since rng.Find.Found is false at the start. A classic exampe of the difference between DO WHILE ... LOOP versus DO ..... LOOP WHILE Whaat happens if you move the DO WHILE to after the .Execute and the LOOP before the final END WITH? On 7 Nov 2019 at 14:37, Susan Harkins wrote: > I had to let this go for awhile but I've got it mostly worked out, > except for the right loop. > > This procedure creates a new document with a table for storing each > acronym, its, definition, and the page number. Right now, it works > fine for the first acronym found, but I can't get the loop correct to > keep it going until it's found all of the acronyms. > > Any help? > > At this point, don't worry if the definition isn't exact. I haven't > been able to test it for a full document -- can't do that until I can > get the loop to work. In addition, it's rather ugly code -- I'll clean > it up later. > > Code follows -- and thanks! - Susan H. > > > Sub GetAcronyms() > 'Create new document with acronyms, definitions, and page numbers for > active document. > > Dim source As Document > Dim target As Document > Dim rng As Range > Dim tbl As Table > Dim strAnronym As String > Dim strDefintion As String > Dim intAcronym As Integer > Dim strRngCopy As String > > Set source = ActiveDocument > Set target = Documents.Add > > 'Add Table object to target document to organize anacronyms and > definitions. With oDoc_Target > Set tbl = target.Tables.Add(target.Range, 2, 3) > With tbl > 'Format the table a bit > 'Insert headings > .Range.Style = wdStyleNormal > .AllowAutoFit = False > .Cell(1, 1).Range.Text = "Acronym" > .Cell(1, 2).Range.Text = "Definition" > .Cell(1, 3).Range.Text = "Page" > 'Set row as heading row > .Rows(1).HeadingFormat = True > .Rows(1).Range.Font.Bold = True > .PreferredWidthType = wdPreferredWidthPercent > .Columns(1).PreferredWidth = 20 > .Columns(2).PreferredWidth = 70 > .Columns(3).PreferredWidth = 10 > End With > End With > > Set rng = source.Range > > 'Do While rng.Find.Found > With rng.Find > 'Use wildcard search to find strings consisting of two or more > uppercase > letters. > .Text = "\(<[A-Z]{2,}>" > .Forward = True > .Wrap = wdFindStop > .Format = False > .MatchCase = True > .MatchWildcards = True > 'Perform the search > .Execute > strAcronym = Right(rng, Len(rng) - 1) > 'Length of strAcronym determines number of words preceding > copied. 'Copy acronym definition. intAcronym = Len(strAcronym) > rng.Select strDefinition = Selection.MoveLeft(wdWord, > intAcronym + 2, True) strDefinition = Selection.Text > > 'Copy acronym, definition, and page number to target table. > With tbl > tbl.Select > Selection.InsertRowsBelow 1 > tbl.Cell(2, 1).Range = strAcronym > tbl.Cell(2, 3).Range.Text = > rng.Information(wdActiveEndPageNumber) > tbl.Cell(2, 2).Range.Text = strDefinition > End With > > End With > 'Loop > > End Sub > > > > -----Original Message----- > From: dba-Tech On Behalf Of > Salakhetdinov Shamil via dba-Tech Sent: Saturday, August 31, 2019 8:09 > AM To: Discussion of Hardware and Software issues > Cc: Salakhetdinov Shamil > Subject: Re: [dba-Tech] Word VBA question > > Hi Susan -- > > I'm not sure what method do you use to find the abbreviation - here > are two possible solution cases: > > *** First one *** > > Sub Macro1() > Dim searchWord As String > searchWord = "BBB" > Dim sel As word.Selection > Set sel = word.Application.Selection > sel.ClearFormatting > With sel.Find > .Text = searchWord > .Replacement.Text = "" > .Forward = True > .Wrap = wdFindContinue > .Format = False > .MatchCase = False > .MatchWholeWord = False > .MatchWildcards = False > .MatchSoundsLike = False > .MatchAllWordForms = False > End With > > Dim wordFound As Boolean > wordFound = sel.Find.Execute > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim wdoc As word.Document > Set wdoc = word.Application.ActiveDocument > > Dim wordIndex As Integer > wordIndex = GetWordIndex(wdoc, sel.Words.First.Start) If (wordIndex > > -1) Then Dim rangeToCopy As word.Range Set rangeToCopy = > wdoc.Range(wdoc.Words(wordIndex - wordLength - 1).Start, > wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String strToCopy = > Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + "'" End If End > If End Sub Function GetWordIndex(wdoc As word.Document, > wordStartPosition As Integer) As Integer Dim wordIndex As Integer > wordFound = False For wordIndex = 1 To wdoc.Words.Count If > (wdoc.Words(wordIndex).Start = wordStartPosition) Then GetWordIndex = > wordIndex Exit Function End If Next wordIndex > > GetWordIndex = -1 > End Function > *** Second one *** > > Sub Macro2() > Dim searchWord As String > searchWord = "BBB" > > Dim wdoc As word.Document > Dim wordIndex As Integer > Dim wordFound As Boolean > > Set wdoc = word.Application.ActiveDocument wordFound = False For > wordIndex = 1 To wdoc.Words.Count If (wdoc.Words(wordIndex) = > searchWord) Then wordFound = True Exit For End If Next wordIndex > > If wordFound Then > Dim wordLength As Integer > wordLength = Strings.Len(searchWord) > Dim rangeToCopy As word.Range > Set rangeToCopy = wdoc.Range(wdoc.Words(wordIndex - wordLength - > 1).Start, wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String > strToCopy = Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + > "'" > > End If > End Sub HTH. > > -- Shamil > > P.S. I'm a rare guest here these days - if you have any questions on > the subject please e-mail me directly. > > > >Tuesday, August 6, 2019 12:21 AM +03:00 from Susan Harkins > : > > > >Hi everyone! > > > >I need to copy a range to a new Word document, but it's a complicated > >search. When the search pattern find a match, I need to select the > >words to the left -- using the length of the match (which can change, > >I'm using wildcards). I'm stumped. > > > >An example: > > > >The search string matches (BBB) at the text, Better Business Bureau > >(BBB). I need to copy the definition of the acronym, to the left of > >BBB, and the acronym. The acronym is easy. But I can't figure out for > >the life of me how to set a range to "three words to the left of > >BBB". > > > >I'd like to avoid using Selection because the editors will be working > >with big documents. If that's the only way it can be done, that's the > >route I'll go. But I'd rather set a range -- just can' figure out how > >to do > it. > > > >Thanks! > >Susan H. > > > >_______________________________________________ > >dba-Tech mailing list > >dba-Tech at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-tech > >Website: http://www.databaseadvisors.com > > > -- > Salakhetdinov Shamil > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From ssharkins at gmail.com Sat Nov 9 05:12:51 2019 From: ssharkins at gmail.com (Susan Harkins) Date: Sat, 9 Nov 2019 06:12:51 -0500 Subject: [dba-Tech] PP clicker problem Message-ID: <004d01d596ee$a139cbc0$e3ad6340$@gmail.com> A reader is trying to use a clicker to trigger a PowerPoint trigger button. I feel like this should work, but I can't find anything on it after just a bit of research. I don't actually give presentations, I just write about PP techniques. Is this a known issue/problem? I don't even know what questions to ask him. Thanks in advance! Susan H. From stuart at lexacorp.com.pg Sat Nov 9 05:59:42 2019 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Sat, 09 Nov 2019 21:59:42 +1000 Subject: [dba-Tech] Word VBA question In-Reply-To: <003301d596ee$29b5f0b0$7d21d210$@gmail.com> References: <04c501d54bd3$a42ad1f0$ec8075d0$@gmail.com>, <2077710002.587209823.1573262604962.JavaMail.zimbra@shaw.ca>, <003301d596ee$29b5f0b0$7d21d210$@gmail.com> Message-ID: <5DC6AA2E.1963.845075B@stuart.lexacorp.com.pg> Just a a WAG, but the faliure to add may be to do with your nested WITHs. Try it with fully qualified references without any WITH...END WITH blocks. On 9 Nov 2019 at 6:09, Susan Harkins wrote: > Yes; before the find is triggered, .Found is false -- nothing has been > found. When I move the loop after .Execute, the loop iterates, but it > doesn't add the found strings to the new document. When there's no > loop, everything works as expected one time -- it finds and copies the > strings to the new document once. > > The documents will have been strings to copy. > > Susan H. > > -----Original Message----- > From: dba-Tech On Behalf Of > Jim Lawrence Sent: Friday, November 8, 2019 8:23 PM To: Discussion of > Hardware and Software issues Subject: > Re: [dba-Tech] Word VBA question > > Hi Susan: > > Is that false condition what you are expecting? > > Jim > > ----- Original Message ----- > From: "Susan Harkins" > To: "Discussion of Hardware and Software issues" > > Sent: Friday, November 8, 2019 6:17:10 AM > Subject: Re: [dba-Tech] Word VBA question > > There's no count with a Do While loop -- the loop continues as long as > the condition is true. As Stuart pointed out my loop is always false > because the search string hasn't been found yet. It works after the > Execute method, but the values aren't copied to the new document. > > > > Susan H. > > > Hi Susan: > > I know nothing (very little) about working with documents but when > using a do..while or for-next loop, getting the count value is most > important. States can change, in some cases for no apparent reason. A > fixed value will not. > > If there is a problem with getting an appropriate response that is > where I would start looking. > > Jim > > ----- Original Message ----- > From: "Susan Harkins" > To: "Discussion of Hardware and Software issues" > > Sent: Thursday, November 7, 2019 12:17:17 PM > Subject: Re: [dba-Tech] Word VBA question > > I tried moving it to just after Execute -- that didn't work either. > > Do While rng.Find doesn't work either. > > Susan H > > > The Do... Loop will not execute since rng.Find.Found is false at the > start. > > A classic exampe of the difference between > > DO WHILE > ... > LOOP > > versus > > DO > ..... > LOOP WHILE > > Whaat happens if you move the DO WHILE to after the .Execute and the > LOOP before the final END WITH? > > > On 7 Nov 2019 at 14:37, Susan Harkins wrote: > > > I had to let this go for awhile but I've got it mostly worked out, > > except for the right loop. > > > > This procedure creates a new document with a table for storing each > > acronym, its, definition, and the page number. Right now, it works > > fine for the first acronym found, but I can't get the loop correct > > to keep it going until it's found all of the acronyms. > > > > Any help? > > > > At this point, don't worry if the definition isn't exact. I haven't > > been able to test it for a full document -- can't do that until I > > can get the loop to work. In addition, it's rather ugly code -- I'll > > clean it up later. > > > > Code follows -- and thanks! - Susan H. > > > > > > Sub GetAcronyms() > > 'Create new document with acronyms, definitions, and page numbers > > for active document. > > > > Dim source As Document > > Dim target As Document > > Dim rng As Range > > Dim tbl As Table > > Dim strAnronym As String > > Dim strDefintion As String > > Dim intAcronym As Integer > > Dim strRngCopy As String > > > > Set source = ActiveDocument > > Set target = Documents.Add > > > > 'Add Table object to target document to organize anacronyms and > > definitions. With oDoc_Target > > Set tbl = target.Tables.Add(target.Range, 2, 3) > > With tbl > > 'Format the table a bit > > 'Insert headings > > .Range.Style = wdStyleNormal > > .AllowAutoFit = False > > .Cell(1, 1).Range.Text = "Acronym" > > .Cell(1, 2).Range.Text = "Definition" > > .Cell(1, 3).Range.Text = "Page" > > 'Set row as heading row > > .Rows(1).HeadingFormat = True > > .Rows(1).Range.Font.Bold = True > > .PreferredWidthType = wdPreferredWidthPercent > > .Columns(1).PreferredWidth = 20 > > .Columns(2).PreferredWidth = 70 > > .Columns(3).PreferredWidth = 10 > > End With > > End With > > > > Set rng = source.Range > > > > 'Do While rng.Find.Found > > With rng.Find > > 'Use wildcard search to find strings consisting of two or more > > uppercase > > letters. > > .Text = "\(<[A-Z]{2,}>" > > .Forward = True > > .Wrap = wdFindStop > > .Format = False > > .MatchCase = True > > .MatchWildcards = True > > 'Perform the search > > .Execute > > strAcronym = Right(rng, Len(rng) - 1) > > 'Length of strAcronym determines number of words preceding > > copied. 'Copy acronym definition. intAcronym = > > Len(strAcronym) rng.Select strDefinition = > > Selection.MoveLeft(wdWord, intAcronym + 2, True) > > strDefinition = Selection.Text > > > > 'Copy acronym, definition, and page number to target table. > > With tbl > > tbl.Select > > Selection.InsertRowsBelow 1 > > tbl.Cell(2, 1).Range = strAcronym > > tbl.Cell(2, 3).Range.Text = > > rng.Information(wdActiveEndPageNumber) > > tbl.Cell(2, 2).Range.Text = strDefinition > > End With > > > > End With > > 'Loop > > > > End Sub > > > > > > > > -----Original Message----- > > From: dba-Tech On Behalf Of > > Salakhetdinov Shamil via dba-Tech Sent: Saturday, August 31, 2019 > > 8:09 AM To: Discussion of Hardware and Software issues > > Cc: Salakhetdinov Shamil > > Subject: Re: [dba-Tech] Word VBA question > > > > Hi Susan -- > > > > I'm not sure what method do you use to find the abbreviation - here > > are two possible solution cases: > > > > *** First one *** > > > > Sub Macro1() > > Dim searchWord As String > > searchWord = "BBB" > > Dim sel As word.Selection > > Set sel = word.Application.Selection > > sel.ClearFormatting > > With sel.Find > > .Text = searchWord > > .Replacement.Text = "" > > .Forward = True > > .Wrap = wdFindContinue > > .Format = False > > .MatchCase = False > > .MatchWholeWord = False > > .MatchWildcards = False > > .MatchSoundsLike = False > > .MatchAllWordForms = False > > End With > > > > Dim wordFound As Boolean > > wordFound = sel.Find.Execute > > If wordFound Then > > Dim wordLength As Integer > > wordLength = Strings.Len(searchWord) > > Dim wdoc As word.Document > > Set wdoc = word.Application.ActiveDocument > > > > Dim wordIndex As Integer > > wordIndex = GetWordIndex(wdoc, sel.Words.First.Start) If (wordIndex > > > -1) Then Dim rangeToCopy As word.Range Set rangeToCopy = > > wdoc.Range(wdoc.Words(wordIndex - wordLength - 1).Start, > > wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String strToCopy = > > Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + "'" End If > > End If End Sub Function GetWordIndex(wdoc As word.Document, > > wordStartPosition As Integer) As Integer Dim wordIndex As Integer > > wordFound = False For wordIndex = 1 To wdoc.Words.Count If > > (wdoc.Words(wordIndex).Start = wordStartPosition) Then GetWordIndex > > = wordIndex Exit Function End If Next wordIndex > > > > GetWordIndex = -1 > > End Function > > *** Second one *** > > > > Sub Macro2() > > Dim searchWord As String > > searchWord = "BBB" > > > > Dim wdoc As word.Document > > Dim wordIndex As Integer > > Dim wordFound As Boolean > > > > Set wdoc = word.Application.ActiveDocument wordFound = False For > > wordIndex = 1 To wdoc.Words.Count If (wdoc.Words(wordIndex) = > > searchWord) Then wordFound = True Exit For End If Next wordIndex > > > > If wordFound Then > > Dim wordLength As Integer > > wordLength = Strings.Len(searchWord) > > Dim rangeToCopy As word.Range > > Set rangeToCopy = wdoc.Range(wdoc.Words(wordIndex - wordLength - > > 1).Start, wdoc.Words(wordIndex - 1).Start) Dim strToCopy As String > > strToCopy = Strings.Trim(rangeToCopy) Debug.Print "'" + strToCopy + > > "'" > > > > End If > > End Sub HTH. > > > > -- Shamil > > > > P.S. I'm a rare guest here these days - if you have any questions on > > the subject please e-mail me directly. > > > > > > >Tuesday, August 6, 2019 12:21 AM +03:00 from Susan Harkins > > : > > > > > >Hi everyone! > > > > > >I need to copy a range to a new Word document, but it's a > > >complicated search. When the search pattern find a match, I need to > > >select the words to the left -- using the length of the match > > >(which can change, I'm using wildcards). I'm stumped. > > > > > >An example: > > > > > >The search string matches (BBB) at the text, Better Business Bureau > > > (BBB). I need to copy the definition of the acronym, to the left > > >of BBB, and the acronym. The acronym is easy. But I can't figure > > >out for the life of me how to set a range to "three words to the > > >left of BBB". > > > > > >I'd like to avoid using Selection because the editors will be > > >working with big documents. If that's the only way it can be done, > > >that's the route I'll go. But I'd rather set a range -- just can' > > >figure out how to do > > it. > > > > > >Thanks! > > >Susan H. > > > > > >_______________________________________________ > > >dba-Tech mailing list > > >dba-Tech at databaseadvisors.com > > >http://databaseadvisors.com/mailman/listinfo/dba-tech > > >Website: http://www.databaseadvisors.com > > > > > > -- > > Salakhetdinov Shamil > > _______________________________________________ > > dba-Tech mailing list > > dba-Tech at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-tech > > Website: http://www.databaseadvisors.com > > > > _______________________________________________ > > dba-Tech mailing list > > dba-Tech at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-tech > > Website: http://www.databaseadvisors.com > > > > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > From fuller.artful at gmail.com Wed Nov 13 15:26:22 2019 From: fuller.artful at gmail.com (Arthur Fuller) Date: Wed, 13 Nov 2019 16:26:22 -0500 Subject: [dba-Tech] External USB problems Message-ID: I cannot figure out why my two external USB port link-banks are unrecognised. Perhaps it's that One has 5 ports and the other 10, and neither work. They used to but as of a month ago they both ceased to work. I have no ides how to find the failing point, other than to disconnect everything then test each external directly into the port, verify that each works, and if they don't, discard them, and if they do, move on until done. If each individual works, then the problem is the multi-port things. They're cheap and maybe that's the problem. But I'm looking for a more scientific approach to the solution than my humble resources can offer. Suggestions -- Arthur From peter.brawley at earthlink.net Wed Nov 13 17:39:06 2019 From: peter.brawley at earthlink.net (Peter Brawley) Date: Wed, 13 Nov 2019 17:39:06 -0600 Subject: [dba-Tech] External USB problems In-Reply-To: References: Message-ID: <0b16ae55-3e04-9c16-b77a-9291ca59ff15@earthlink.net> On 11/13/2019 15:26, Arthur Fuller wrote: > I cannot figure out why my two external USB port link-banks are > unrecognised. Perhaps it's that One has 5 ports and the other 10, and > neither work. They used to but as of a month ago they both ceased to work. > I have no ides how to find the failing point, other than to disconnect > everything then test each external directly into the port, verify that each > works, and if they don't, discard them, and if they do, move on until done. > If each individual works, then the problem is the multi-port things. > They're cheap and maybe that's the problem. But I'm looking for a more > scientific approach to the solution than my humble resources can offer. > Suggestions Many USB hubs, esp. cheap ones, have little power capacity, often not enough for even a small portable drive, so it might be your hubs work for low-powered thingies like a mouse, but not for a something that needs more power. PB > From accessd at shaw.ca Thu Nov 14 14:59:11 2019 From: accessd at shaw.ca (Jim Lawrence) Date: Thu, 14 Nov 2019 13:59:11 -0700 (MST) Subject: [dba-Tech] External USB problems In-Reply-To: References: Message-ID: <684822978.617480835.1573765151043.JavaMail.zimbra@shaw.ca> Hi Arthur: Have you tested the initial USB port, the one that is attached to your computer? Is it working? Jim ----- Original Message ----- From: "Arthur Fuller" To: "Discussion of Hardware and Software issues" Sent: Wednesday, November 13, 2019 1:26:22 PM Subject: [dba-Tech] External USB problems I cannot figure out why my two external USB port link-banks are unrecognised. Perhaps it's that One has 5 ports and the other 10, and neither work. They used to but as of a month ago they both ceased to work. I have no ides how to find the failing point, other than to disconnect everything then test each external directly into the port, verify that each works, and if they don't, discard them, and if they do, move on until done. If each individual works, then the problem is the multi-port things. They're cheap and maybe that's the problem. But I'm looking for a more scientific approach to the solution than my humble resources can offer. Suggestions -- Arthur _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From garykjos at gmail.com Thu Nov 14 15:59:39 2019 From: garykjos at gmail.com (Gary Kjos) Date: Thu, 14 Nov 2019 15:59:39 -0600 Subject: [dba-Tech] External USB problems In-Reply-To: References: Message-ID: Try and plug them into one of your other computers and see if they work there. Does any USB device work on the port you are plugged into? Perhaps it's the port itself. Odd that they would both fail at once. Is there another port on the computer you are using you could plug them into? Did you look at the devices in Device Manager? Might be worth trying to delete them and then reboot and let Windows re-add them. On Wed, Nov 13, 2019 at 3:28 PM Arthur Fuller wrote: > > I cannot figure out why my two external USB port link-banks are > unrecognised. Perhaps it's that One has 5 ports and the other 10, and > neither work. They used to but as of a month ago they both ceased to work. > I have no ides how to find the failing point, other than to disconnect > everything then test each external directly into the port, verify that each > works, and if they don't, discard them, and if they do, move on until done. > If each individual works, then the problem is the multi-port things. > They're cheap and maybe that's the problem. But I'm looking for a more > scientific approach to the solution than my humble resources can offer. > Suggestions > > -- > Arthur > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com -- Gary Kjos garykjos at gmail.com From rockysmolin at bchacc.com Sun Nov 17 16:20:43 2019 From: rockysmolin at bchacc.com (rockysmolin bchacc.com) Date: Sun, 17 Nov 2019 22:20:43 +0000 Subject: [dba-Tech] Screens Flipped Message-ID: Dear Lists: Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. I can't figure out how to get them back. Does anyone know? Mil gracias in advance, Rocky From garykjos at gmail.com Sun Nov 17 16:27:17 2019 From: garykjos at gmail.com (Gary Kjos) Date: Sun, 17 Nov 2019 16:27:17 -0600 Subject: [dba-Tech] [dba-OT] Screens Flipped In-Reply-To: References: Message-ID: Easy way is to switch the cables. ;-) On Sun, Nov 17, 2019 at 4:21 PM rockysmolin bchacc.com wrote: > > Dear Lists: > > Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. > > In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. > > I can't figure out how to get them back. > > Does anyone know? > > Mil gracias in advance, > > Rocky > -- Gary Kjos garykjos at gmail.com From rockysmolin at bchacc.com Sun Nov 17 16:36:40 2019 From: rockysmolin at bchacc.com (rockysmolin bchacc.com) Date: Sun, 17 Nov 2019 22:36:40 +0000 Subject: [dba-Tech] [dba-OT] Screens Flipped In-Reply-To: References: Message-ID: Thanks for the idea. I tried to do that. One display is HDMI and one is VGA. I wasn't sure if the HDMI display had a VGA jack as well. So I started to turn it around to see. As I did the comp made a sound that indicated a device was unplugged. Then, the displays righted themselves. WTF??!! Now I have no idea what caused it OR what fixed it. :-| But if it ain't broke... Best, r -----Original Message----- From: dba-OT [mailto:dba-ot-bounces at databaseadvisors.com] On Behalf Of Gary Kjos Sent: Sunday, November 17, 2019 2:27 PM To: Off Topic Cc: List (dba-tech at databaseadvisors.com) Subject: Re: [dba-OT] Screens Flipped Easy way is to switch the cables. ;-) On Sun, Nov 17, 2019 at 4:21 PM rockysmolin bchacc.com wrote: > > Dear Lists: > > Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. > > In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. > > I can't figure out how to get them back. > > Does anyone know? > > Mil gracias in advance, > > Rocky > -- Gary Kjos garykjos at gmail.com From jbartow at winhaven.net Sun Nov 17 20:45:47 2019 From: jbartow at winhaven.net (John Bartow) Date: Mon, 18 Nov 2019 02:45:47 +0000 Subject: [dba-Tech] Screens Flipped In-Reply-To: References: Message-ID: Go into display properties and click and drag the right monitor to the left. As easy as it is unintuitive. -----Original Message----- From: dba-Tech On Behalf Of rockysmolin bchacc.com Sent: Sunday, November 17, 2019 4:21 PM To: List (dba-tech at databaseadvisors.com) ; Off Topic Subject: [dba-Tech] Screens Flipped Dear Lists: Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. I can't figure out how to get them back. Does anyone know? Mil gracias in advance, Rocky _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From rockysmolin at bchacc.com Sun Nov 17 21:12:50 2019 From: rockysmolin at bchacc.com (rockysmolin bchacc.com) Date: Mon, 18 Nov 2019 03:12:50 +0000 Subject: [dba-Tech] Screens Flipped In-Reply-To: References: Message-ID: Easy :) But it didn't work. :( That was my first approach. I don't know why that didn't work. There are an update installed last night I was going to uninstall that next. But did you read my post to Gary about the solution. THAT was unintuitive. I still don't know how it worked or why. Still don't know how it was caused or why. One step away from my go to solution - percussive maintenance. r -----Original Message----- From: dba-Tech [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of John Bartow via dba-Tech Sent: Sunday, November 17, 2019 6:46 PM To: Discussion of Hardware and Software issues Cc: John Bartow Subject: Re: [dba-Tech] Screens Flipped Go into display properties and click and drag the right monitor to the left. As easy as it is unintuitive. -----Original Message----- From: dba-Tech On Behalf Of rockysmolin bchacc.com Sent: Sunday, November 17, 2019 4:21 PM To: List (dba-tech at databaseadvisors.com) ; Off Topic Subject: [dba-Tech] Screens Flipped Dear Lists: Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. I can't figure out how to get them back. Does anyone know? Mil gracias in advance, Rocky _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From accessd at shaw.ca Mon Nov 18 00:01:42 2019 From: accessd at shaw.ca (Jim Lawrence) Date: Sun, 17 Nov 2019 23:01:42 -0700 (MST) Subject: [dba-Tech] Screens Flipped In-Reply-To: References: Message-ID: <840563691.635023004.1574056902497.JavaMail.zimbra@shaw.ca> Hi Rocky: Unfortunately, a Windows10 update that borks the system is not unusual. I have no idea why a bad release happens but in some cases the only solution is to roll back everything to the previous version and then wait for the faulty update to be fixed before attempting another install. Check out the following: https://www.howtogeek.com/235474/how-to-roll-back-builds-and-uninstall-updates-on-windows-10/ http://bit.ly/32XFip4 HTH Jim ----- Original Message ----- From: "rockysmolin" To: "Discussion of Hardware and Software issues" Sent: Sunday, November 17, 2019 7:12:50 PM Subject: Re: [dba-Tech] Screens Flipped Easy :) But it didn't work. :( That was my first approach. I don't know why that didn't work. There are an update installed last night I was going to uninstall that next. But did you read my post to Gary about the solution. THAT was unintuitive. I still don't know how it worked or why. Still don't know how it was caused or why. One step away from my go to solution - percussive maintenance. r -----Original Message----- From: dba-Tech [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of John Bartow via dba-Tech Sent: Sunday, November 17, 2019 6:46 PM To: Discussion of Hardware and Software issues Cc: John Bartow Subject: Re: [dba-Tech] Screens Flipped Go into display properties and click and drag the right monitor to the left. As easy as it is unintuitive. -----Original Message----- From: dba-Tech On Behalf Of rockysmolin bchacc.com Sent: Sunday, November 17, 2019 4:21 PM To: List (dba-tech at databaseadvisors.com) ; Off Topic Subject: [dba-Tech] Screens Flipped Dear Lists: Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. I can't figure out how to get them back. Does anyone know? Mil gracias in advance, Rocky _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From df.waters at outlook.com Mon Nov 18 10:09:19 2019 From: df.waters at outlook.com (Daniel Waters) Date: Mon, 18 Nov 2019 16:09:19 +0000 Subject: [dba-Tech] [dba-OT] Screens Flipped In-Reply-To: References: Message-ID: Perhaps turning the monitor 'jiggled' the cable connection a little - which was enough for the newly updated W10 to 'relearn' which monitor was actually where and how they should be. And they should have been where they were to start with! :-) Dan -----Original Message----- From: dba-Tech [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of rockysmolin bchacc.com Sent: November 17, 2019 16:37 To: Off Topic Cc: List (dba-tech at databaseadvisors.com) Subject: Re: [dba-Tech] [dba-OT] Screens Flipped Thanks for the idea. I tried to do that. One display is HDMI and one is VGA. I wasn't sure if the HDMI display had a VGA jack as well. So I started to turn it around to see. As I did the comp made a sound that indicated a device was unplugged. Then, the displays righted themselves. WTF??!! Now I have no idea what caused it OR what fixed it. :-| But if it ain't broke... Best, r -----Original Message----- From: dba-OT [mailto:dba-ot-bounces at databaseadvisors.com] On Behalf Of Gary Kjos Sent: Sunday, November 17, 2019 2:27 PM To: Off Topic Cc: List (dba-tech at databaseadvisors.com) Subject: Re: [dba-OT] Screens Flipped Easy way is to switch the cables. ;-) On Sun, Nov 17, 2019 at 4:21 PM rockysmolin bchacc.com wrote: > > Dear Lists: > > Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. > > In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. > > I can't figure out how to get them back. > > Does anyone know? > > Mil gracias in advance, > > Rocky > -- Gary Kjos garykjos at gmail.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From rockysmolin at bchacc.com Mon Nov 18 10:31:44 2019 From: rockysmolin at bchacc.com (rockysmolin bchacc.com) Date: Mon, 18 Nov 2019 16:31:44 +0000 Subject: [dba-Tech] [dba-OT] Screens Flipped In-Reply-To: References: Message-ID: Good theory. But I'm going with magic... "Any sufficiently advanced technology is indistinguishable from magic." Arthur C. Clarke :) r -----Original Message----- From: dba-Tech [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of Daniel Waters Sent: Monday, November 18, 2019 8:09 AM To: Discussion of Hardware and Software issues Subject: Re: [dba-Tech] [dba-OT] Screens Flipped Perhaps turning the monitor 'jiggled' the cable connection a little - which was enough for the newly updated W10 to 'relearn' which monitor was actually where and how they should be. And they should have been where they were to start with! :-) Dan -----Original Message----- From: dba-Tech [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of rockysmolin bchacc.com Sent: November 17, 2019 16:37 To: Off Topic Cc: List (dba-tech at databaseadvisors.com) Subject: Re: [dba-Tech] [dba-OT] Screens Flipped Thanks for the idea. I tried to do that. One display is HDMI and one is VGA. I wasn't sure if the HDMI display had a VGA jack as well. So I started to turn it around to see. As I did the comp made a sound that indicated a device was unplugged. Then, the displays righted themselves. WTF??!! Now I have no idea what caused it OR what fixed it. :-| But if it ain't broke... Best, r -----Original Message----- From: dba-OT [mailto:dba-ot-bounces at databaseadvisors.com] On Behalf Of Gary Kjos Sent: Sunday, November 17, 2019 2:27 PM To: Off Topic Cc: List (dba-tech at databaseadvisors.com) Subject: Re: [dba-OT] Screens Flipped Easy way is to switch the cables. ;-) On Sun, Nov 17, 2019 at 4:21 PM rockysmolin bchacc.com wrote: > > Dear Lists: > > Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. > > In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. > > I can't figure out how to get them back. > > Does anyone know? > > Mil gracias in advance, > > Rocky > -- Gary Kjos garykjos at gmail.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From jbartow at winhaven.net Mon Nov 18 12:42:15 2019 From: jbartow at winhaven.net (John Bartow) Date: Mon, 18 Nov 2019 18:42:15 +0000 Subject: [dba-Tech] Screens Flipped In-Reply-To: References: Message-ID: Just did. Sounds like your cables aren't tightened on one end or the other. OR it could be one of your display ports has a weak connection, I'd guess the HDMI. But sometimes you just leave well enough alone! I have 6 monitors. This morning Dell informed me that there was a driver update. So I went ahead and installed it and kept working. All was fine until Brenda came down to discuss something. As she reached around to my desk for a stamp the screens all went black except the main display which moved to the lower right monitor and went to about 200% size. I just laughed and said "There you go! You haven't lost your touch with technology!" Of course I knew what was happening restarted and all was well (luckily). Otherwise it would have been roll back driver time. So this week I can foresee numerous calls from clients that thought they should click that update (even though they've all been told that they should never agree to install anything). I'll send a remote restart command and they will be happy with my mgt. services once more, lol. John Bartow WinHaven Consulting -----Original Message----- From: dba-Tech On Behalf Of rockysmolin bchacc.com Sent: Sunday, November 17, 2019 9:13 PM To: Discussion of Hardware and Software issues Subject: Re: [dba-Tech] Screens Flipped Easy :) But it didn't work. :( That was my first approach. I don't know why that didn't work. There are an update installed last night I was going to uninstall that next. But did you read my post to Gary about the solution. THAT was unintuitive. I still don't know how it worked or why. Still don't know how it was caused or why. One step away from my go to solution - percussive maintenance. r -----Original Message----- From: dba-Tech [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of John Bartow via dba-Tech Sent: Sunday, November 17, 2019 6:46 PM To: Discussion of Hardware and Software issues Cc: John Bartow Subject: Re: [dba-Tech] Screens Flipped Go into display properties and click and drag the right monitor to the left. As easy as it is unintuitive. -----Original Message----- From: dba-Tech On Behalf Of rockysmolin bchacc.com Sent: Sunday, November 17, 2019 4:21 PM To: List (dba-tech at databaseadvisors.com) ; Off Topic Subject: [dba-Tech] Screens Flipped Dear Lists: Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. I can't figure out how to get them back. Does anyone know? Mil gracias in advance, Rocky _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From accessd at shaw.ca Tue Nov 19 14:54:46 2019 From: accessd at shaw.ca (Jim Lawrence) Date: Tue, 19 Nov 2019 13:54:46 -0700 (MST) Subject: [dba-Tech] Screens Flipped In-Reply-To: References: Message-ID: <319897838.644298031.1574196886561.JavaMail.zimbra@shaw.ca> Hi John/Rocky: I am sure Microsoft is aware of the problems and will have the corrected updates soon. A week to two weeks at the most. Jim ----- Original Message ----- From: "Discussion of Hardware and Software issues" To: "Discussion of Hardware and Software issues" Cc: "John R Bartow" Sent: Monday, November 18, 2019 10:42:15 AM Subject: Re: [dba-Tech] Screens Flipped Just did. Sounds like your cables aren't tightened on one end or the other. OR it could be one of your display ports has a weak connection, I'd guess the HDMI. But sometimes you just leave well enough alone! I have 6 monitors. This morning Dell informed me that there was a driver update. So I went ahead and installed it and kept working. All was fine until Brenda came down to discuss something. As she reached around to my desk for a stamp the screens all went black except the main display which moved to the lower right monitor and went to about 200% size. I just laughed and said "There you go! You haven't lost your touch with technology!" Of course I knew what was happening restarted and all was well (luckily). Otherwise it would have been roll back driver time. So this week I can foresee numerous calls from clients that thought they should click that update (even though they've all been told that they should never agree to install anything). I'll send a remote restart command and they will be happy with my mgt. services once more, lol. John Bartow WinHaven Consulting -----Original Message----- From: dba-Tech On Behalf Of rockysmolin bchacc.com Sent: Sunday, November 17, 2019 9:13 PM To: Discussion of Hardware and Software issues Subject: Re: [dba-Tech] Screens Flipped Easy :) But it didn't work. :( That was my first approach. I don't know why that didn't work. There are an update installed last night I was going to uninstall that next. But did you read my post to Gary about the solution. THAT was unintuitive. I still don't know how it worked or why. Still don't know how it was caused or why. One step away from my go to solution - percussive maintenance. r -----Original Message----- From: dba-Tech [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of John Bartow via dba-Tech Sent: Sunday, November 17, 2019 6:46 PM To: Discussion of Hardware and Software issues Cc: John Bartow Subject: Re: [dba-Tech] Screens Flipped Go into display properties and click and drag the right monitor to the left. As easy as it is unintuitive. -----Original Message----- From: dba-Tech On Behalf Of rockysmolin bchacc.com Sent: Sunday, November 17, 2019 4:21 PM To: List (dba-tech at databaseadvisors.com) ; Off Topic Subject: [dba-Tech] Screens Flipped Dear Lists: Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. I can't figure out how to get them back. Does anyone know? Mil gracias in advance, Rocky _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From jbartow at winhaven.net Wed Nov 20 09:58:40 2019 From: jbartow at winhaven.net (John Bartow) Date: Wed, 20 Nov 2019 15:58:40 +0000 Subject: [dba-Tech] Screens Flipped In-Reply-To: <319897838.644298031.1574196886561.JavaMail.zimbra@shaw.ca> References: <319897838.644298031.1574196886561.JavaMail.zimbra@shaw.ca> Message-ID: Wow Jim, is that the optimist in you coming out? ? -----Original Message----- From: dba-Tech On Behalf Of Jim Lawrence Sent: Tuesday, November 19, 2019 2:55 PM To: Discussion of Hardware and Software issues Subject: Re: [dba-Tech] Screens Flipped Hi John/Rocky: I am sure Microsoft is aware of the problems and will have the corrected updates soon. A week to two weeks at the most. Jim ----- Original Message ----- From: "Discussion of Hardware and Software issues" To: "Discussion of Hardware and Software issues" Cc: "John R Bartow" Sent: Monday, November 18, 2019 10:42:15 AM Subject: Re: [dba-Tech] Screens Flipped Just did. Sounds like your cables aren't tightened on one end or the other. OR it could be one of your display ports has a weak connection, I'd guess the HDMI. But sometimes you just leave well enough alone! I have 6 monitors. This morning Dell informed me that there was a driver update. So I went ahead and installed it and kept working. All was fine until Brenda came down to discuss something. As she reached around to my desk for a stamp the screens all went black except the main display which moved to the lower right monitor and went to about 200% size. I just laughed and said "There you go! You haven't lost your touch with technology!" Of course I knew what was happening restarted and all was well (luckily). Otherwise it would have been roll back driver time. So this week I can foresee numerous calls from clients that thought they should click that update (even though they've all been told that they should never agree to install anything). I'll send a remote restart command and they will be happy with my mgt. services once more, lol. John Bartow WinHaven Consulting -----Original Message----- From: dba-Tech On Behalf Of rockysmolin bchacc.com Sent: Sunday, November 17, 2019 9:13 PM To: Discussion of Hardware and Software issues Subject: Re: [dba-Tech] Screens Flipped Easy :) But it didn't work. :( That was my first approach. I don't know why that didn't work. There are an update installed last night I was going to uninstall that next. But did you read my post to Gary about the solution. THAT was unintuitive. I still don't know how it worked or why. Still don't know how it was caused or why. One step away from my go to solution - percussive maintenance. r -----Original Message----- From: dba-Tech [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of John Bartow via dba-Tech Sent: Sunday, November 17, 2019 6:46 PM To: Discussion of Hardware and Software issues Cc: John Bartow Subject: Re: [dba-Tech] Screens Flipped Go into display properties and click and drag the right monitor to the left. As easy as it is unintuitive. -----Original Message----- From: dba-Tech On Behalf Of rockysmolin bchacc.com Sent: Sunday, November 17, 2019 4:21 PM To: List (dba-tech at databaseadvisors.com) ; Off Topic Subject: [dba-Tech] Screens Flipped Dear Lists: Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. I can't figure out how to get them back. Does anyone know? Mil gracias in advance, Rocky _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com From accessd at shaw.ca Wed Nov 20 15:03:42 2019 From: accessd at shaw.ca (Jim Lawrence) Date: Wed, 20 Nov 2019 14:03:42 -0700 (MST) Subject: [dba-Tech] Screens Flipped In-Reply-To: References: <319897838.644298031.1574196886561.JavaMail.zimbra@shaw.ca> Message-ID: <503469240.650184025.1574283822459.JavaMail.zimbra@shaw.ca> A little of both. In the business a bad call is damaging and a good call is expected. Jim ----- Original Message ----- From: "Discussion of Hardware and Software issues" To: "Discussion of Hardware and Software issues" Cc: "John R Bartow" Sent: Wednesday, November 20, 2019 7:58:40 AM Subject: Re: [dba-Tech] Screens Flipped Wow Jim, is that the optimist in you coming out? ? -----Original Message----- From: dba-Tech On Behalf Of Jim Lawrence Sent: Tuesday, November 19, 2019 2:55 PM To: Discussion of Hardware and Software issues Subject: Re: [dba-Tech] Screens Flipped Hi John/Rocky: I am sure Microsoft is aware of the problems and will have the corrected updates soon. A week to two weeks at the most. Jim ----- Original Message ----- From: "Discussion of Hardware and Software issues" To: "Discussion of Hardware and Software issues" Cc: "John R Bartow" Sent: Monday, November 18, 2019 10:42:15 AM Subject: Re: [dba-Tech] Screens Flipped Just did. Sounds like your cables aren't tightened on one end or the other. OR it could be one of your display ports has a weak connection, I'd guess the HDMI. But sometimes you just leave well enough alone! I have 6 monitors. This morning Dell informed me that there was a driver update. So I went ahead and installed it and kept working. All was fine until Brenda came down to discuss something. As she reached around to my desk for a stamp the screens all went black except the main display which moved to the lower right monitor and went to about 200% size. I just laughed and said "There you go! You haven't lost your touch with technology!" Of course I knew what was happening restarted and all was well (luckily). Otherwise it would have been roll back driver time. So this week I can foresee numerous calls from clients that thought they should click that update (even though they've all been told that they should never agree to install anything). I'll send a remote restart command and they will be happy with my mgt. services once more, lol. John Bartow WinHaven Consulting -----Original Message----- From: dba-Tech On Behalf Of rockysmolin bchacc.com Sent: Sunday, November 17, 2019 9:13 PM To: Discussion of Hardware and Software issues Subject: Re: [dba-Tech] Screens Flipped Easy :) But it didn't work. :( That was my first approach. I don't know why that didn't work. There are an update installed last night I was going to uninstall that next. But did you read my post to Gary about the solution. THAT was unintuitive. I still don't know how it worked or why. Still don't know how it was caused or why. One step away from my go to solution - percussive maintenance. r -----Original Message----- From: dba-Tech [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of John Bartow via dba-Tech Sent: Sunday, November 17, 2019 6:46 PM To: Discussion of Hardware and Software issues Cc: John Bartow Subject: Re: [dba-Tech] Screens Flipped Go into display properties and click and drag the right monitor to the left. As easy as it is unintuitive. -----Original Message----- From: dba-Tech On Behalf Of rockysmolin bchacc.com Sent: Sunday, November 17, 2019 4:21 PM To: List (dba-tech at databaseadvisors.com) ; Off Topic Subject: [dba-Tech] Screens Flipped Dear Lists: Last night there was, apparently, a Windows Update. Today I found that my dual monitor extended displays were flipped. The opening Win display was on the right instead of the left. And to get the mouse from the right display to the left display I had to move it to the right off the right hand display and then it re-appeared on the left side of the left hand display. In display settings the rearrange your displays window shows them where they were and flipping them doesn't change anything. I can't figure out how to get them back. Does anyone know? Mil gracias in advance, Rocky _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com