pedro at plex.nl
pedro at plex.nl
Thu Dec 2 17:07:37 CST 2010
Hello Shamil, the code works. Thanks. I will adjust the code for the proper use and it isn't necessary to help me with a code for itering trough a folder. That i can do myself. Thanks again. Pedro if somebody here have time to help Pedro to write the > code iterating through a folder with MS Word docs, opening docs, > substituting tabs using above code, saving changes, closing current doc, > opening another one ... please jump in. In antwoord op: > From: "Shamil Salakhetdinov" <shamil at smsconsulting.spb.ru> > To: "'Access Developers discussion and problem solving'" > Date: Thu, 2 Dec 2010 18:39:37 +0300 > Subject: Re: [AccessD] MS-Word import into Access > > > Pedro, > > Then you can use it like that: > > 1. Start MS Word > 2. Create empty doc > 3. Switch to VBE > 4. Insert module into blank doc modules > 5. Copy and paste the following code into module: > > Option Explicit > > Public Sub ReplaceTabsInActiveDoc() > ReplaceTabs Application.ActiveDocument > End Sub > > Public Sub ReplaceTabs(ByRef rdoc As Word.Document) > Dim wapp As Word.Application > Set wapp = rdoc.Application > rdoc.Select > With wapp.Selection.Find > .Text = "^t" > .Replacement.Text = ";" > .Forward = True > .Wrap = 1 'wdFindContinue > .Format = False > .MatchCase = False > .MatchWholeWord = False > .MatchAllWordForms = False > .MatchSoundsLike = False > .MatchWildcards = True > End With > wapp.Selection.Find.Execute Replace:=2 'wdReplaceAll > > Set wapp = Nothing > End Sub > > 6. Open test document > 7. Switch back to VBE > 8. Put cursor on code line > > Public Sub ReplaceTabsInActiveDoc() > > 9. Push [F5] > .... > > You can also save macro within normal.dot (MS Word 97 - 2003) but better not > do that. > > If you're going to use the above code by opening every document manually > then you don't need that code at all - just use in MS Word: > > - Ctrl+H > - char to be replaced - ^t > - char to replace with - ; > - [Replace All] > > Application of the above code makes sense to automate tabs replacement in a > (large) set of docs - if somebody here have time to help Pedro to write the > code iterating through a folder with MS Word docs, opening docs, > substituting tabs using above code, saving changes, closing current doc, > opening another one ... please jump in... > > I have quite some work to do here, sorry.... > > Thank you. > > -- > Shamil > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of pedro at plex.nl > Sent: 2 ??????? 2010 ?. 15:34 > To: " > 'AccessDevelopersdiscussionandproblemsolving'" at mailhostC.plex.net > Cc: AccessD at databaseadvisors.com > Subject: Re: [AccessD] MS-Word import into Access > > Hello Shamil, > > i would like to use your proposed vba code as a macro in the word document, > not from within access. > > Pedro > > > > In antwoord op: > > > From: "Shamil Salakhetdinov" <shamil at smsconsulting.spb.ru> > > To: "'Access Developers discussion and problem solving'" > > Date: Thu, 2 Dec 2010 16:55:43 +0300 > > Subject: Re: [AccessD] MS-Word import into Access > > > > > > Pedro, > > > > Do you use proposed VBA code from within MS Access VBE? > > > > Thank you. > > > > -- > > Shamil > > > > -----Original Message----- > > From: accessd-bounces at databaseadvisors.com > > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of > > pedro at plex.nl > > Sent: 2 ??????? 2010 ?. 14:39 > > To: AccessD at databaseadvisors.com > > Subject: Re: [AccessD] MS-Word import into Access > > > > Hello Shamil, > > > > Thanks for the code. > > when i make a new macro from your code. > > The code is not accepted as a macro. > > > > When using the sub ReplaceTabs name, or another sub name, closing the > > visual basic editor, and go to macro's, the macro is not present. > > > > I has something to do with the reference: (ByRef rdoc As > > Word.Document) When using it after the sub-name the macro isn't > > recognized a macro, and i can't start the macro (also not from within the > visual basic editor). > > When i don't use it after the sub-name, i get an error: object not > present. > > and Set wapp = rdoc.Application is highlighted. > > Any suggestions? > > > > Pedro > > > > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > >