From: slickdock on 22 Oct 2009 13:19 Thank you both. I won't even have to go this route if I can get an answer to this question. I posted it in OLE Interoperability and User Designed Forms with no reply...Can you help? I have a merge doc that has this command: {DATABASE \d "c:\\tmp\\odbc.mdb" \s "select * from \"t_address\" } The t_address table has one field only: the address. I need the addresses to be in a certain sort order, so I tried adding a number field to the table. This fixes the sort order problem, but now the number field gets inserted into my word doc along with the address. Is there a way to specifiy that I only want the address field to insert into my doc? "Pesach Shelnitz" wrote: > Hi, > > The Word enumerations are documented with the values of all the constants in > the MSDN Libraray (http://www.msdn.com). To find a value, open the MSDN > Library and search for the applicable enumeration or constant. For example, > the value of wdFindContinue is documented at > http://msdn.microsoft.com/en-us/library/bb213734.aspx, and > the value of wdReplaceAll is documented at > http://msdn.microsoft.com/en-us/library/bb238124.aspx. > > -- > Hope this helps, > Pesach Shelnitz > > > "slickdock" wrote: > > > Thank you. I prefer to learn how to, as you suggest, look up the actual > > values in the Word object model and use them instead of the constant names. > > How do I do that? How do I "look up values in the Word object model?" Sorry, > > I'm a beginner... > > > > "Peter Jamieson" wrote: > > > > > have you "made a reference" to the Word object (i.e. with the VBA module > > > open, go to Tools->References, locate the appropriate "Microsoft Word > > > Object" library, and check it)? > > > > > > If you haven't, then constants such as wdFindContinue and wdReplaceAll > > > will not have the correct values and the macro will likely fail. > > > > > > Alternatively, you can look up the actual values in the Word object > > > model and use them instead of the constant names. > > > > > > Peter Jamieson > > > > > > http://tips.pjmsn.me.uk > > > Visit Londinium at http://www.ralphwatson.tv > > > > > > On 21/10/2009 17:36, slickdock wrote: > > > > I posted this in VBA for beginners, but got no reply. I'll try here... > > > > > > > > I have this simple macro in word, and I'd like to execute it from an msAccess > > > > module: > > > > > > > > Selection.Find.ClearFormatting > > > > Selection.Find.Replacement.ClearFormatting > > > > With Selection.Find > > > > .Text = "a" > > > > .Replacement.Text = "b" > > > > .Forward = True > > > > .Wrap = wdFindContinue > > > > .Format = False > > > > .MatchCase = False > > > > .MatchWholeWord = False > > > > .MatchWildcards = False > > > > .MatchSoundsLike = False > > > > .MatchAllWordForms = False > > > > End With > > > > Selection.Find.Execute Replace:=wdReplaceAll > > > > > > > > I know enough to preface the above code with: > > > > Dim wd As Object > > > > Dim wdActiveDoc As Object > > > > Dim wdField As Object > > > > Set wd = CreateObject("Word.Application") > > > > > > > > Then I know enough to add the following wd. prefix to these lines: > > > > wd.Selection.Find.ClearFormatting > > > > wd.Selection.Find.Replacement.ClearFormatting > > > > With wd.Selection.Find > > > > > > > > But after the END WITH, it's bombing out on this line: > > > > wd.Selection.Find.Execute Replace:=wdReplaceAll > > > > > > > > Any help would be greatly appreciated. > > > . > > >
From: Pesach Shelnitz on 23 Oct 2009 05:45 Hi, Try replacing the asterisk (*) by the name of the field (something like t_address.address) that you want to include. The asterisk selects all the fields. Also you need another quotation mark at the end to close the quotation mark before the word select. -- Hope this helps, Pesach Shelnitz "slickdock" wrote: > Thank you both. I won't even have to go this route if I can get an answer to > this question. I posted it in OLE Interoperability and User Designed Forms > with no reply...Can you help? > > I have a merge doc that has this command: > > {DATABASE \d "c:\\tmp\\odbc.mdb" \s "select * from \"t_address\" } > > The t_address table has one field only: the address. > > I need the addresses to be in a certain sort order, so I tried adding a > number field to the table. This fixes the sort order problem, but now the > number field gets inserted into my word doc along with the address. Is there > a way to specifiy that I only want the address field to insert into my doc? > > > "Pesach Shelnitz" wrote: > > > Hi, > > > > The Word enumerations are documented with the values of all the constants in > > the MSDN Libraray (http://www.msdn.com). To find a value, open the MSDN > > Library and search for the applicable enumeration or constant. For example, > > the value of wdFindContinue is documented at > > http://msdn.microsoft.com/en-us/library/bb213734.aspx, and > > the value of wdReplaceAll is documented at > > http://msdn.microsoft.com/en-us/library/bb238124.aspx. > > > > -- > > Hope this helps, > > Pesach Shelnitz > > > > > > "slickdock" wrote: > > > > > Thank you. I prefer to learn how to, as you suggest, look up the actual > > > values in the Word object model and use them instead of the constant names. > > > How do I do that? How do I "look up values in the Word object model?" Sorry, > > > I'm a beginner... > > > > > > "Peter Jamieson" wrote: > > > > > > > have you "made a reference" to the Word object (i.e. with the VBA module > > > > open, go to Tools->References, locate the appropriate "Microsoft Word > > > > Object" library, and check it)? > > > > > > > > If you haven't, then constants such as wdFindContinue and wdReplaceAll > > > > will not have the correct values and the macro will likely fail. > > > > > > > > Alternatively, you can look up the actual values in the Word object > > > > model and use them instead of the constant names. > > > > > > > > Peter Jamieson > > > > > > > > http://tips.pjmsn.me.uk > > > > Visit Londinium at http://www.ralphwatson.tv > > > > > > > > On 21/10/2009 17:36, slickdock wrote: > > > > > I posted this in VBA for beginners, but got no reply. I'll try here... > > > > > > > > > > I have this simple macro in word, and I'd like to execute it from an msAccess > > > > > module: > > > > > > > > > > Selection.Find.ClearFormatting > > > > > Selection.Find.Replacement.ClearFormatting > > > > > With Selection.Find > > > > > .Text = "a" > > > > > .Replacement.Text = "b" > > > > > .Forward = True > > > > > .Wrap = wdFindContinue > > > > > .Format = False > > > > > .MatchCase = False > > > > > .MatchWholeWord = False > > > > > .MatchWildcards = False > > > > > .MatchSoundsLike = False > > > > > .MatchAllWordForms = False > > > > > End With > > > > > Selection.Find.Execute Replace:=wdReplaceAll > > > > > > > > > > I know enough to preface the above code with: > > > > > Dim wd As Object > > > > > Dim wdActiveDoc As Object > > > > > Dim wdField As Object > > > > > Set wd = CreateObject("Word.Application") > > > > > > > > > > Then I know enough to add the following wd. prefix to these lines: > > > > > wd.Selection.Find.ClearFormatting > > > > > wd.Selection.Find.Replacement.ClearFormatting > > > > > With wd.Selection.Find > > > > > > > > > > But after the END WITH, it's bombing out on this line: > > > > > wd.Selection.Find.Execute Replace:=wdReplaceAll > > > > > > > > > > Any help would be greatly appreciated. > > > > . > > > >
First
|
Prev
|
Pages: 1 2 Prev: VBA numbering off headings Next: Saving pdf file embedded in word doc |