Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / March 2005

Tip: Looking for answers? Try searching our database.

VBA - Data extraction from rtf file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tom blower - 04 Mar 2005 09:55 GMT
Merge uses data from a rtf file. I need to be able to get code to
extract data from one of the fields in the rtf file, which contains
the path and file name to be used when saving the merge result. I do
not want to have to hard-code this which is the easy solution.

Could someone kindly tell me if this is possible and (if so) how to
achieve it?

Access slots the designated path and file name into one of the fields
in the table which is then output as a rtf file followed by code to
start Word and run the merge in the selected template, which is linked
to the rtf file.

Thanks

Tom
Peter Jamieson - 04 Mar 2005 10:49 GMT
Assuming you are using VBA to execute the merge and save the output, you can
use e.g.

ActiveDocument.MailMerge.DataSource.DataFields("mypathname").Value

to get the value of  a field called "mypathname" in the currently loaded
data source record.

Peter Jamieson

> Merge uses data from a rtf file. I need to be able to get code to
> extract data from one of the fields in the rtf file, which contains
[quoted text clipped - 12 lines]
>
> Tom
tom blower - 05 Mar 2005 09:07 GMT
Thanks Peter. I wish I could understand the Word object library.
Yes, I am controlling the merge with VBA. I have also found another
way of dealing with this.

Within Access,
>objWord.ActiveDocument.Variables.Add.Name:="VariableName",
Value:="Whatever"
inserted on the line before
>objWord.Run "'ActiveDocument' !Module1.MergeIt"
which starts Word

Within Word
>ActiveDocument.SaveAs
FileName:=ActiveDocument.Variables("VariableName").Value,  etc

Since I am already putting the required data into the rtf file and
your neat  code is all that is required in each template module, I
will adopt your solution. Many thanks.

Tom
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.