Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jun 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro in Word 2000 to open 'SaveAs' (VBA - Word 2000)

    Hi, I'm trying to put a macro into a Word 2000 document which I have set the file to read only. The macro currently copies and pastes some stuff and leaves what I want the filename to be in the Windows clipboard. I need the macro to open the "SaveAs" dialoge and past the buffer into the filename spot.
    I at least want the "SaveAs" opened... I can punch Ctrl-V if I have to.

    I am currently using the line:
    If ActiveDocument.Save = False Then ActiveDocument.Save
    but I get a "Run-time error '5155' This file is read-only" and I click "End" and continue with my work.
    I would just as soon not have to exit from an error every time I do this though.
    Thanks for any advise.
    David
    megnin@nortelnetworks.com

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Macro in Word 2000 to open 'SaveAs' (VBA - Word 2000)

    To get the text from the paste buffer
    <pre>Dim objPasteData As New DataObject
    Dim strFileName As String

    objPasteData.GetFromClipboard
    strFileName = objPasteData.GetText
    </pre>

    To save the file
    <pre> ActiveDocument.SaveAs FileName:=strFileName
    </pre>

    or if you need to display the Save As dialog box so the user can make changes then
    <pre>With Dialogs(wdDialogFileSaveAs)
    .Name = strFileName
    If .Display = -1 Then .Execute
    End With
    </pre>

    StuartR

  3. #3
    New Lounger
    Join Date
    Jun 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro in Word 2000 to open 'SaveAs' (VBA - Word 2000

    Thanks StuartR! That's a big help!

Posting Permissions

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