| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Wrtiting to word from access
Hi
I have an access database and I want to create a vba script that opens a document in word, and changes some data based on information in a query/form. (sort of simulating a mail merge). My current code is as follows (at the moment just not final code - just need to first work out how to replace text in word): Dim oApp As Object Set oApp = CreateObject("Word.Application") Dim Mergedoc As String Mergedoc = Application.CurrentProject.Path Mergedoc = Mergedoc + "\documentname.doc" Dim oword As Object Set oApp = GetObject(Mergedoc) oApp.Windows(1).Visible = True With oApp.Activewindow With .Selection.Find .Text = "<12345>" .Replacement.Text = "hello" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With .Selection.Find.Execute Replace:=wdReplaceAll End With Set oApp = Nothing I've looked around and this seems to be code that should work - it should open word, do a find and replace.. However, it stops by just leaving the word that needs to be replaced highlighted - it doesn't finish off the task. Any ideas?!?! |
![]() |
| Viewing: Tutorialized Forums > Databases > MS Access > Wrtiting to word from access |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|