Reply
 
Thread Tools Display Modes
  #1   Report Post  
tom blower
 
Posts: n/a
Default VBA - Data extraction from rtf file

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
  #2   Report Post  
Peter Jamieson
 
Posts: n/a
Default

Assuming you are using VBA to execute the merge and save the output, you can
use e.g.

ActiveDocument.MailMerge.DataSource.DataFields("my pathname").Value

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

Peter Jamieson



"tom blower" wrote in message
om...
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



  #3   Report Post  
tom blower
 
Posts: n/a
Default

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:="Varia bleName",

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
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging Label Form File with Data File Becky N Mailmerge 7 February 18th 05 05:47 PM
Save file as .doc having all data in ascii character set Freddy Microsoft Word Help 1 February 3rd 05 09:44 AM
Word Field Codes in Excel data file mranz Mailmerge 7 December 11th 04 09:02 AM
To select data from across worksheets in a excel file for a main . Salaivani Mailmerge 1 December 1st 04 01:08 AM


All times are GMT +1. The time now is 08:39 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"