CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 1999
    Location
    Ireland
    Posts
    12

    Saving a document in a temporary file

    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



  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Saving a document in a temporary file

    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.


  3. #3
    Join Date
    Jan 2000
    Posts
    45

    Re: Saving a document in a temporary file

    Open "c:\whatever\whatever.doc" For Output As #1
    s = Text1
    Write #1, s
    Close #1



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured