Error with Access VBA & Word Enumerators

totalnovice2

Registered User.
Local time
Today, 21:21
Joined
May 21, 2013
Messages
36
Hi.

I have the code below and I would like to save it as a .doc file which is a 97 version, i.e FileFormat:=Word.WdSaveFormat.wdFormatDocument97

I think that i have done this the right way but the receipient of the e-mail (using office 2003) can't open the file as it says "cannot open filename etc but doesn't give a reason"

If I send a 97.doc without using the template file on the below, and just open then save&send it will open the file without issue.

PLEASE HELP!

Code:
Private Sub Command152_Click()
 
'Declare the follwing
    Dim objWord As Word.Application
       'Set word as an application and make it invisible
         Set objWord = CreateObject("Word.Application")
         objWord.Visible = False 'True is visible
 
       'path and name of the template
         objWord.Documents.Add ("[URL="https://office.me.com/sites/radioandrigginpermits/Auto/Vod%20Permitnew.dot"]https://office.[COLOR=#ff4400]me[/COLOR].com/sites/radioandrigginpermits/Auto/Vod%20Permitnew.dot[/URL]")
 
       'This is for the bookmark
         objWord.ActiveDocument.Bookmarks("VFCS").Select
 
       'This is the field in access that containts the data that has to be entered at the
       'bookmark
         objWord.Selection.Text = Forms![Front Page]![Site 2 Owner]
 
 
         objWord.ActiveDocument.Bookmarks("VFNAME").Select
        objWord.Selection.Text = Forms![Front Page]![Site 2 Name]
 
 
'Word (or the documentwill now open if true)
    objWord.Visible = False
 
       objWord.ActiveDocument.SaveAs2 FileName:="C:\Users\Public\" & " " & Forms![Front Page]![Combo79] & " " & "VF" & ".doc", _
       FileFormat:=Word.WdSaveFormat.wdFormatDocument97
 
 
       Call Mail_Radio_Outlook2("C:\Users\Public\" & " " & Forms![Front Page]![Combo79] & " " & "VF" & ".doc")
 
        objWord.ActiveDocument.Close
 
 Set objWord = Nothing
End Sub
 
Can you open the generated document on your C drive?
 
Hi. I can open the files on my computer but the recipient that uses office 2003 advises that it is still being sent as a .dotm template file so it looks like the coding for the file format doesn't work properly?
 
objWord.ActiveDocument.SaveAs "C:\Users\Public\" & " " & Forms![Front Page]![Combo79] & " " & "VF" & ".doc", wdFormatDocument97

seems to work for me.

BTW, you don't get a syntax error with SaveAs2?
 
I generated a document using code in Word2007 and opened the document on a PC running Word2003.
 
Thanks for your responses.

I will give it a go using saveas instead of saveas2.

No I haven't been given a syntax error using the 2 suffix which is why I have been confused as to what is happening.

Fingers crossed.
 

Users who are viewing this thread

Back
Top Bottom