Kim Wiggins
kimjwiggins at yahoo.com
Mon Jul 25 22:04:13 CDT 2005
Hey all, I am really trying to make this word Automation work. I am using VB to write the code but it will not recognize the bookmarks. It opens the document and everything like it should but it will not recognize the book mark. The error I get is this: the requested member of the collection does not exist It bombs out at the green highlighted code and I can't understand why. Any help would be greatly appreciated. Thanks Kim Here is my code Private Sub cmdLogEntry_Click() ' Declare the variable. Dim objWD As Word.Application Dim WordDoc As Word.Document Dim WordRange As Word.Range Dim strPath As String ' Set the variable (runs new instance of Word.) Set objWD = CreateObject("Word.Application") 'make application visible objWD.Application.Visible = True 'Get Path of Current DB strPath = "C:\AMS\AMS.mdb" 'Strip FileName to Get Path to Doc Do lngInStr = InStr(lngInStr + 1, strPath, "\") Loop While (InStr(lngInStr + 1, strPath, "\") <> 0) 'Get path up to the last \ strPath = Left(strPath, lngInStr) 'Append document name onto the end of the stripped path strPath = strPath & "AirframeTemplate.doc" 'open the word document Set doc = objWD.Documents.Open(strPath) 'Insert text into bookmark objWD.ActiveDocument.Bookmarks.Item(AT).Range.Text = frmAircraftWO.txtAircraftType ' Quit Word. objWD.Quit ' Clear the variable from memory. Set objWD = Nothing End Sub __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com