B
Brett Kinross via AccessMonster.com
Hello everyone
Using Word 2002 and Access 2002.
I have developed code to enable merging of data to different Word documents.
The problem lies in that when you merge to a new word document the Text Form
Fields Are Not Retained During Mail Merge.
This is a known problem which is detailed in the following document:
http://support.microsoft.com/default.aspx?scid=kb;en-us;286841
The above document also has a workaround macro in VBA from Word in which it
substitutes placeholders before the merge and then puts the text form Fields
back in after the merge.
I am having two problems with this code when automating from Access:
1) It has a variable called "aField" which isn't declared. This works fine
within Word but not Access. If you substitute "aField" for "fField" which is
a declared FormField variable it appears to work. Anyone know why the code
uses "aField" and why it works in Word but not Access?
2) The following line of code:
Selection.TypeText "<" & fFieldText(1, iCount) & "PlaceHolder>"
works fine within Word but can't get it to work in Access. In Access I have
tried it with:
WordDoc.Selection.TypeText "<" & fFieldText(1, iCount) & "PlaceHolder>"
where WordDoc is a declared object variable that is set to the Word Document.
I have also tried:
Wordapp.ActiveDocument.Selection.TypeText "<" & fFieldText(1, iCount) &
"PlaceHolder>"
where Wordapp is a declared object variable for Word.Application.
The error I always get is: "Object doesn't support this property or method."
Does anyone know how to typetext from Access to Word to the selected area?
Thanks for any assistance
Brett
Using Word 2002 and Access 2002.
I have developed code to enable merging of data to different Word documents.
The problem lies in that when you merge to a new word document the Text Form
Fields Are Not Retained During Mail Merge.
This is a known problem which is detailed in the following document:
http://support.microsoft.com/default.aspx?scid=kb;en-us;286841
The above document also has a workaround macro in VBA from Word in which it
substitutes placeholders before the merge and then puts the text form Fields
back in after the merge.
I am having two problems with this code when automating from Access:
1) It has a variable called "aField" which isn't declared. This works fine
within Word but not Access. If you substitute "aField" for "fField" which is
a declared FormField variable it appears to work. Anyone know why the code
uses "aField" and why it works in Word but not Access?
2) The following line of code:
Selection.TypeText "<" & fFieldText(1, iCount) & "PlaceHolder>"
works fine within Word but can't get it to work in Access. In Access I have
tried it with:
WordDoc.Selection.TypeText "<" & fFieldText(1, iCount) & "PlaceHolder>"
where WordDoc is a declared object variable that is set to the Word Document.
I have also tried:
Wordapp.ActiveDocument.Selection.TypeText "<" & fFieldText(1, iCount) &
"PlaceHolder>"
where Wordapp is a declared object variable for Word.Application.
The error I always get is: "Object doesn't support this property or method."
Does anyone know how to typetext from Access to Word to the selected area?
Thanks for any assistance
Brett