troubleshooting Question

Saving Word Document from Access 2003

Avatar of hopelessinsalem
hopelessinsalem asked on
Microsoft AccessMicrosoft Word
15 Comments1 Solution955 ViewsLast Modified:
We have this database created when everyone had Office 2003 or earlier installed on their computers.  The code snippet that I pasted was found on this site, and modified for our use and worked flawlessly.....that is until now.

There are two users who now have Word 2007 on their computers, and thus lies the following issue:

If you look through the code, you will see where, from Access, the Word document is automatically saved with a specific file name.  This works for all users no matter what the Word Version.  However, The user with Word 2007 is the ONLY one who can further view the created word document.  It will open up just fine.  The user with Word 2003, when trying to open the word document created from the 2007 user, sees nothing but 'garble' and a window pops up with an error saying:

"File Conversion - Select the encoding that makes the document readable"

Now, if the 2003 user runs access, and creates a document, this error does not occur and is readable by both users.

I know in Word 2007, there is a SAVE AS 2003 document option, and I am wondering if there is some coding that needs to be done to correct this issue from happening?  Is there a way to check the version of Word that is open and thus run some different code to make sure that when the person with 2007 creates a new document and is saved that the 2003 people can still view the documents?


Private Sub RunWordTemplate_Click()
On Error GoTo Err_RunWordTemplate_Click
 
    Dim intAnswerMe As Integer
    
    'Fill in Work Order Description if blank to avoid Null error in Word
    If IsNull(Me.WODesc.Value) Or _
    Me.WODesc = 0 Then
        intAnswerMe = MsgBox("Please enter in a Work Order Description", vbOKOnly + vbInformation, "Description Needed")
        Me.WODesc.SetFocus
        Exit Sub
    End If
        
    Dim oApp As Object      'Variable for Word
    Dim sFilename As String 'Variable for Auto-Save file name
    Dim strTemplateName As String   'Variable for Word Template to be used
    Dim objWORDdoc As Object
    
    'Save Record
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    
    'Create path to Quotation Template
    strTemplateName = "\\Sharppc\ServerFiles\ProjectData\Quotations\QuotationTemp.dot"
    'Create default SaveName for New Quotation being written
    sFilename = "\\Sharppc\ServerFiles\ProjectData\Quotations\" & Me.WONum.Value & " - " & Me.CompanyName.Value & ".doc"
    
    Set oApp = CreateObject("Word.Application")
    oApp.Visible = True
    
    If Dir(sFilename) = "" Then                 'Test to see if created filename already exists
                                                'and if not, open Template to fill in date
        Set oApp = CreateObject("word.basic")   'otherwise just open that filename already
        With oApp
            
            .filenew Template:=strTemplateName
            'Set bookmarks in QuotationTemp to equal values of new Quoation Number created
            .EditBookmark Name:="quotedate", GoTo:=True
            .Insert (Format(Me.WODate, "mmmm dd, yyyy")) 'insert date of quote
            .EditBookmark Name:="quotenum", GoTo:=True
            .Insert (CStr(Me.WONum))                    'insert work order number
            .EditBookmark Name:="companyname", GoTo:=True
            .Insert (CStr(Me.CompanyName))              'insert company name
            
            'This code will make sure that if the street address has two lines, both are inserted
            If IsNull(DLookup("[CustAdd2]", "ContactsTbl", "[Contact]='" & Me.Contact.Value & "'")) Or _
            DLookup("[CustAdd2]", "ContactsTbl", "[Contact]='" & Me.Contact.Value & "'") = 0 Then
                .EditBookmark Name:="address", GoTo:=True   'insert Line 1 address
                .Insert ((CStr(DLookup("[CustAdd1]", "ContactsTbl", "[Contact]='" & Me.Contact.Value & "'"))))
            Else
                .EditBookmark Name:="address", GoTo:=True   'insert Line 1 & 2 address
                .Insert (CStr(DLookup("[CustAdd1]", "ContactsTbl", "[Contact]='" & Me.Contact.Value & "'"))) & vbCrLf & (CStr(DLookup("[CustAdd2]", "ContactsTbl", "[Contact]='" & Me.Contact.Value & "'")))
            End If
            
            .EditBookmark Name:="citystate", GoTo:=True
            .Insert ((CStr(DLookup("[CustCity]", "ContactsTbl", "[Contact]='" & Me.Contact.Value & "'"))) & ", " & (CStr(DLookup("[StateID]", "ContactsTbl", "[Contact]='" & Me.Contact.Value & "'"))) & " " & (CStr(DLookup("[CustZip]", "ContactsTbl", "[Contact]='" & Me.Contact.Value & "'"))))
            .EditBookmark Name:="custname", GoTo:=True
            .Insert (CStr(Me.Contact))
            .EditBookmark Name:="subject", GoTo:=True
            .Insert (CStr(Me.WODesc))
            .EditBookmark Name:="firstname", GoTo:=True
            .Insert (CStr(DLookup("[fName]", "ContactsTbl", "[Contact]='" & Me.Contact.Value & "'")) & ",")
            
            .filesaveas Name:=sFilename 'save Quotation with auto save name
            
        End With
        
        Else    'If filename already exists, just open the file at this point
            
            oApp.Documents.Open sFilename
            oApp.ActiveDocument.Save
            
        End If
 
Exit_RunWordTemplate_Click:
    Exit Sub
 
Err_RunWordTemplate_Click:
    MsgBox Err.Description
    Resume Exit_RunWordTemplate_Click
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros