the main problem is caused by the program reference, once I put ms word object reference. I can include it. so my current code for open and save is:
Public Sub OpenDocument(DocName)
If gnWordVersion = 95 Then
'Word 95 format
W.FileOpen (App.path & "\" & DocName) ', 0, 0, 0, "", "", 0, "", ""
Else
'Word 97 format
W.Documents.Open (App.path & "\" & DocName), ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", format:=wdOpenFormatAuto
End If
End Sub
Public Sub SaveDocument(DocName As String)
On Error GoTo WError
If gnWordVersion = 95 Then
'Word 95 format eg
W.FileSaveAs App.path & "\" & DocName, 0, 0, "", 1, "", 0, 0, 0, 0, 0
Else
'Word 97 format
W.ActiveDocument.SaveAs App.path & "\" & DocName, FileFormat:=wdOpenFormatAuto, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
End If
Exit Sub
WError:
MsgBox DocName & " is currently active, please close it and run the same function once again." 'save the newer one with the same name to overwrite it."
'inuseW = True
'don't do anything
End Sub
But, even after I use that code. I still cannot save .doc in word 2007 yet.
I haven't tried to save .docx yet though.. maybe it will work.
thanks a lot