Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a TextBox object on a Word document

Status
Not open for further replies.

tunsarod

Programmer
Oct 31, 2001
294
GB
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
 
may help you get started

Sub test()
Dim oShape As Shape

For Each oShape In ActiveDocument.Shapes
oShape.TextFrame.TextRange.Text = "yahoo!"
Next oShape
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top