MS Access
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Tutorialized ForumsDatabasesMS Access

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
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  
Old December 9th, 2007, 07:38 PM
izzyk izzyk is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 3 izzyk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 14 sec
Reputation Power: 0
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?!?!

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesMS Access > Wrtiting to word from access


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway