Automation Problem Exporting To Word

C

CyndyG

I am trying to get information from my Access form to a Word document that is
bookmarked. I am receiving the following error:214741851(80010105). I have
also read and went to some of the links that show some of the examples of
doing this,but none of them work for me. This may be a Microsoft Professional
Support question,but I hope someone here can help me. Here is the code.

rivate Sub cmdCallTemplate_Click()
Const AssociateHandOff As String = "Associates Hand-Off"
Const AssociateHandOff2 As String = "Associate picks up from point"
Const ArmoredService As String = "Armored Service"
Const ArmoredService2 As String = "Armored services notifies MediaMovement
Office(MMO)package is in their possession"
Const IronMountain As String = "Iron Mountain"
Const IronMountain2 As String = "will provide statement of work"
Const AssociateHandles As String = "Associate Handles All Travel"
Const AssociateHandles2 As String = "Travels with media from point of origin"
Const Corporate As String = "Corporate Aviation"
Const Corporate2 As String = "Corporate acquired aircraft is in route"
Const ArmoredServiceDestination As String = "Armored Service"
Const ArmoredServiceDestination2 As String = "Destination - Use Armored
service to meet aircraft"
Const Destinations As String = "Destinations"
Const Destinations2 As String = "Use Armored service to meet aircraft"

Dim rst As DAO.Recordset
Dim objDoc As Object
Dim objDoc2 As Object
Dim strTab As String
Dim strLFCR As String

Dim str1 As String
Dim str2 As String
strTab = Chr$(9)
strLFCR = Chr$(13)

Set rst = Me.Recordset
Set objDoc = GetObject("C:\StatementofWork.dot")

objDoc.SaveAs ("C:\StatementofWork.doc")

objDoc.Close
Set objDoc = GetObject("C:\StatementofWork.doc")

objDoc.Bookmarks("strCaseID").Range.Text = Nz(rst.Fields("strCaseID"))
objDoc.Bookmarks("strRequestorName").Range.Text =
Nz(rst.Fields("strRequestorName"))
objDoc.Bookmarks("strRequestorPhone").Range.Text =
Nz(rst.Fields("strRequestorPhone"))
objDoc.Bookmarks("lngPiecesMoved").Range.Text =
Nz(rst.Fields("lngPiecesMoved"))
objDoc.Bookmarks("lngUnitsMoved").Range.Text = Nz(rst.Fields("lngUnitsMoved"))
objDoc.Bookmarks("strEncrypted").Range.Text = Nz(rst.Fields("strEncrypted"))
objDoc.Bookmarks("ysnDERS").Range.Text = Nz(rst.Fields("ysnDERS"))
objDoc.Bookmarks("ysnISER").Range.Text = Nz(rst.Fields("ysnISER"))
objDoc.Bookmarks("strLeavingCity").Range.Text =
Nz(rst.Fields("strLeavingCity"))
objDoc.Bookmarks("strArrivingCity").Range.Text =
Nz(rst.Fields("strArrivingCity"))


'If Me.ysnAssociateHand_Off = True Then
' str1 = AssociateHandOff & strTab & AssociateHandOff2 & strLFCR
' End If

'If Me.ysnArmoredService = True Then
' str1 = str1 & ArmoredService & strTab & ArmoredService2 & strLFCR
' End If

' If Me.ysnironMountain = True Then
' str1 = str1 & IronMountain & strTab & IronMountain2 & strLFCR
' End If

' If Me.ysnAssociateHandles = True Then
' str1 = str1 & AssociateHandles & strTab & AssociateHandles2 & strLFCR
' End If

'If Me.ysnCorporate = True Then
' str1 = str1 & Corporate & strTab & Corporate2 & strLFCR
' End If

' If Me.ysnArmoredServiceDestination = True Then
' str1 = str1 & ArmoredServiceDestination & strTab &
ArmoredServiceDestination2 & strLFCR
' 'End If

' objDoc.Bookmarks("VariableText1").Range.Text = str1

'If Me.ysnDestinations = True Then
' str2 = Destinations & strTab & Destinations2 & strLFCR
' End If

'objDoc.Bookmarks("VariableText2").Range.Text = str2

' objDoc.Parent.Visible = True
' objDoc.Parent.Activate
Set objDoc = Nothing


End Sub


I have some things commented out because I was trying to get the bookmark
section to run.
 
J

John Nurick

I am receiving the following error:214741851(80010105).

I doubt it very much: it should be
-214417851 (80010105).

There are many possible causes. Search http://groups.google.com for
"-214417851" OR 80010105 word bookmark OR bookmarks
and
"-214417851" OR 80010105 word access

If you set a reference to the Word object library and temporarily modify
your code to use early binding you should get a more useful error
message which will help pin down the cause. Also set a breakpoint at the
beginning of the procedure and then step through the code so you can
learn exactly which line is raising the error.

BTW, I suggest you work with an explicit Word application object, e.g.

Dim objWordApp As Word.Application 'use As Object for late binding
Dim objDoc As Word.Document 'ditto

Set objWordApp = CreateObject("Word.Application")
Set objDoc = objWordApp.Documents.Add("C:\StatementofWork.dot")
objDoc.SaveAs "C:\StatementofWork.doc"

'Do stuff with objDoc
...

objDoc.Close True
objWordApp.Quit



If you search http://groups.google.com for
"-214417851" OR 80010105 word bookmark OR bookmarks
and
"-214417851" OR 80010105 word access
 
C

CyndyG

THanks John this worked,but I am having a problem getting word to close. At
one point when I checked Task Manager I had 3 word.exe going. I checked
because when I tried to delete the word document I created a message let me
know I couldn't because Word still had it open.
I did find out what the problems were and corrected them. I don't even know
how I missed the error,I checked the bookmarks quite a few times.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top