Click to See Complete Forum and Search --> : Saving a document in a temporary file


Karl Monaghan
January 20th, 2000, 09:38 AM
Is there a way in VB to save an open document in word so another program (called by the vb macro) can access it? I've tried saving the document twice in a row with different filenames like this:

ActiveDocument.SaveAs filename:="c:\temp\blah.doc"
ActiveDocument.SaveAs filename:="c:\temp\abcdef.doc"



But I still cannot access blah.doc. Any ideas why this is happening and how to get around it?

Thanks,

Karl Monaghan

Lothar Haensler
January 20th, 2000, 10:47 AM
couldn't reproduce that behavior.
I tried this code with VB 6 and Office 2000 on an NT machine:

Dim x as Word.Application
set x = new Word.Application
x.Visible = true
x.Documents.Open "c:\test.txt"
x.ActiveDocument.SaveAs "c:\test.doc"
x.ActiveDocument.SaveAs "c:\test2.doc"
Dim hfile as Integer
hfile = FreeFile
Open "c:\test.doc" for input as #hfile
Dim strZeile as string

Line input #hfile, strZeile

Close hfile
x.ActiveDocument.Close
set x = nothing



no problem opening an reading from the file.

Starcraft
January 20th, 2000, 11:48 AM
Open "c:\whatever\whatever.doc" For Output As #1
s = Text1
Write #1, s
Close #1