Help needed with access 2007/Word 2007

aadebayo

Registered User.
Local time
Today, 15:31
Joined
May 10, 2004
Messages
43
Error using Access 2007 to Open word 2007

I am currently developing an application using MsAccess 2007. As part of the development, I need to create a word document that draws tables and enter data including links to the table. When I run it with Word 2003, everything works perfectly, but when I use Word 2007 I get the following error (attached) as image. The code that generates this error is below. The code causing the error is in bold text. Any help will be appreciated.

Code:
Dim WordExport As Object

Set WordExport = CreateObject("Word.Basic")


 Dim rstIMDoc As New ADODB.Recordset
        Dim rstSys As New ADODB.Recordset
        Dim cnn As New ADODB.Connection
        Dim strSQL As String
        
        Set cnn = CurrentProject.Connection
        strSQL = "select * from tblSys"
        rstSys.Open strSQL, cnn
        g_Doc_Location = rstSys!documentLoc
        g_Temp_Doc = rstSys!templatepath
        g_eMail_Address = rstSys!email_address
        
        strSQL = "select * from vwIMDoc ORDER BY Reference"
        
        Dim lCommands       As Variant
        Dim lCount          As Integer


        rstIMDoc.Open strSQL, cnn
        WordExport.FileOpen (rstSys!documentpath & "\Letters\Public Report.docx")
        WordExport.AppShow
        WordExport.EditGoTo , Destination:="Description"
                         If m_String = "\" Then
                        m_Count = m_Count + 1
                     
                    [B]WordExport.InsertObject Iconnumber:=1, FileName:=g_Doc_Location & (rstIMDoc!DocLocation), Link:=1, displayicon:=1, Tab:="1", Class:="{C184E717-402A-438F-B99E-77C2CD4091C8}", IconFileName:="C:\WINNT\System32\OLE2.DLL", Caption:=Chr$(34) + (rstIMDoc!DocName)[/B]
                        WordExport.nextcell
                    Else
                        WordExport.nextcell
                    End If
            
                    WordExport.Insert (rstIMDoc!DocName)
                    WordExport.nextcell
 

Attachments

  • error message.JPG
    error message.JPG
    15.8 KB · Views: 133
Last edited:
The Class and DLL used in 2003 may be different in 2007 try recording a macro in 2007 and view the code.
 
Thanks DCrake, I have done exactly that, create a macro and then use the code generated, however, I get a different message. It is attached as errormessage2.jpg

The code generated by the macro is below

Code:
  Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.8", FileName _
        := _
        "\\Corporate\ccs\Capital & Asset Management\Document Management\external\business\form templates\Exit interview questionnaire.doc" _
        , LinkToFile:=True, DisplayAsIcon:=True, IconFileName:= _
        "C:\WINDOWS\Installer\{90120000-0030-0000-0000-0000000FF1CE}\wordicon.exe" _
        , IconIndex:=1, IconLabel:="Exit interview questionnaire.doc"
 

Attachments

  • error message2.JPG
    error message2.JPG
    12.8 KB · Views: 115
Have you referenced word in your access app?
 

Users who are viewing this thread

Back
Top Bottom