Results 1 to 17 of 17

Thread: Solved: MS Word - Filename argument of SaveAs Method of ActiveDocument

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Solved: MS Word - Filename argument of SaveAs Method of ActiveDocument

    Hallo Guys,

    In Word, I want to take the text in a textbox in the active document and use it as the filename for the active document by using the SaveAs method. Here is the code:

    [vba]
    Sub Rename_ActiveDocument()
    Dim NewFileName As String
    NewFileName = ActiveDocument.Shapes("Text Box 2").TextFrame.TextRange.Text
    ActiveDocument.SaveAs FileName:=NewFileName
    End Sub
    [/vba]

    Unfortunately, I get an error message: Word cannot complete the save due to a file permission error.

    But if I just type the new filename in directly, it saves the file.

    [vba]ActiveDocument.SaveAs FileName:= "Yabadabadoo"[/vba]

    What seems to be the problemo?

    Thanks.

    Last edited by GeoffreyB; 10-28-2008 at 02:02 PM.

Posting Permissions

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