I am using the code below as part of a larger MS Access97 procedure that opens a Word97 template and inserts text into bookmarks on the document. This works well enough but I would like to be able to place the address string "strAddr" directly into a text box on the Word document template using the same approach as below. However, search as I might, I have been unable to discover the correct method of accessing a TextBox object in a Word application document from Access. I have tried reviewing Word VB Help, Access VB Help and trawling through the Object Browser for both Word and Access without any success. I assume that the correct code will look something like...
.Selection.Goto wdGotoTextbox, Name:="Textbox(0)
.Selection.TypeText strValue
...but guessing won't do it. Anybody got a solution, please?
Here is the current code:
With appWord
' Open a new document based on the named template
.Documents.Add strFile
' Switch off automatic spell checking
.ActiveDocument.ShowSpellingErrors = False
'Commence bookmark selection and text insertion process
.Selection.Goto wdGoToBookmark, Name:="Attention"
.Selection.typetext strWhoTo & " "
.Selection.Goto wdGoToBookmark, Name:="DelAddress"
.Selection.typetext strAddrVrt & " "
.Selection.Goto wdGoToBookmark, Name:="TodaysDate"
.Selection.typetext Format(Date, "Long Date"
.Selection.Goto wdGoToBookmark, Name:="Endearment"
.Selection.typetext strDear & " "
.Selection.Goto wdGoToBookmark, Name:="Reference"
.Selection.typetext strAddrHrz & " "
.Selection.Goto wdGoToBookmark, Name:="Author"
.Selection.typetext Authorname & " "
End With
Thanks for reading this.
Rod
.Selection.Goto wdGotoTextbox, Name:="Textbox(0)
.Selection.TypeText strValue
...but guessing won't do it. Anybody got a solution, please?
Here is the current code:
With appWord
' Open a new document based on the named template
.Documents.Add strFile
' Switch off automatic spell checking
.ActiveDocument.ShowSpellingErrors = False
'Commence bookmark selection and text insertion process
.Selection.Goto wdGoToBookmark, Name:="Attention"
.Selection.typetext strWhoTo & " "
.Selection.Goto wdGoToBookmark, Name:="DelAddress"
.Selection.typetext strAddrVrt & " "
.Selection.Goto wdGoToBookmark, Name:="TodaysDate"
.Selection.typetext Format(Date, "Long Date"
.Selection.Goto wdGoToBookmark, Name:="Endearment"
.Selection.typetext strDear & " "
.Selection.Goto wdGoToBookmark, Name:="Reference"
.Selection.typetext strAddrHrz & " "
.Selection.Goto wdGoToBookmark, Name:="Author"
.Selection.typetext Authorname & " "
End With
Thanks for reading this.
Rod