I have a VB6 form with an OLE object that create/open/edit/save Word files.
The code:
'--------------- BEGIN --------------------------
Private Sub cmdEdit_Click()
OLE1.DoVerb vbOLEShow
End Sub
Private Sub cmdSave_Click()
OLE1.SaveToFile OLE1.FileNumber
End Sub
Private Sub cmdNew_Click()
OLE1.Close
OLE1.CreateEmbed "", "Word.Document.8"
OLE1.SourceDoc = "abc.doc"
OLE1.Refresh
End Sub
Private Sub cmdExit_Click()
OLE1.Close
OLE1.Delete
Unload Me
End Sub
Public Sub OpenFile(ByVal sFile As String)
OLE1.CreateEmbed sFile
OLE1.FileNumber = 1
OLE1.DoVerb vbOLEOpen
End Sub
'---------------- END -----------------------
My problem is when I save an opened file appears a run time error (31036 -
Error saving file).
Explanation of this error:
- Visual Basic can't write the object to the specified file (set Action =
11, or 18). Possible causes:
1 -The FileNumber property is invalid.
2 -The specified file wasn't opened in Binary mode.
3 -There isn't enough disk space.
In my case only option 2 maybe valid.
Does anyone know how can I open a file in Binary mode using the OLE Object?
Thx
Start Free Trial