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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a word97 bookmark using VBA.. error

Status
Not open for further replies.

it2hill

IS-IT--Management
Sep 5, 2002
28
US
Good day,

When I run the following code..

Public Function Update_Word()

Dim WordDoc As Object
Dim ActiveDocument As Object

Dim sDocName As String
Set WordDoc = CreateObject("Word.Application")
sDocName = "C:\Temp\mydoc.doc"
Set ActiveDocument = GetObject(sDocName)
ActiveDocument.SaveAs "C:\Temp\mydoc1.doc"

dDate = Me![txtDate]
dtime = Me![txtTime]

ActiveDocument.Bookmarks.Item("Date_Time").Range.Text = "ONE"
ActiveDocument.Save
ActiveDocument.Application.Quit
Set WordDoc = Nothing
End Function

I get a Run-time error '-2147417851 (80010105): Method 'Text' of object 'Range' failed

When I choose debug it drops me to the Bookmark section of code. If I comment that out and let it move on and then go open the new document, the bookmark has the text "ONE" inserted.

What is causing this error? How can I make it go away?

Thanks,

Shane
 
Found it in a previous thread...

thread707-551710 it will help someone else.

Shane
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top