Word VBA Assistance

  • I have a quick question for VBA buffs


    i have to create a macro to prompt for save as, then save, then close the document all using the same keystroke (Alt-E)


    it is simple im sure, im just missing an important line of code here or there


    any help at all is much appreciated!!

  • Re: Word VBA Assistance


    Hi Sin....


    is that first name sin, second name thetic...? :)


    Anyway, I know nothing about Word Macros, but just recorded the actions you described below in a macro.... The result looked like this -



    Note - you say in your post, you want to 'save as' then 'save' and close the document. I'm not sure if you really wanted to go "save as" and then "save". Not much point in doing the two when there will be no changes between the "save as" and "save". Does that make sense? Anyway, just remove ActiveDocument.Save if you dont want to do two saves.


    HTH
    Ger

    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont. :P


    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25... ;)

    _______________________________________________

  • Re: Word VBA Assistance


    thanks for the reply Ger, i had tryed something like what you posted before and it didnt work the way i need it to


    what i need is a Keystroke to prompt for the filename and directory (the save as dialog box)


    thanks again

  • Re: Word VBA Assistance


    Why dont you just assign a key stroke to the macro?
    Ger

    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont. :P


    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25... ;)

    _______________________________________________

  • Re: Word VBA Assistance


    what i tryed (the easy way) is the record the macro with the assigned keystroke and just click save as...but i cant stop the recording without closing the dialog box or saving the file....


    basically, all i need is to be able to hit a keystroke and the save as dialog box appears and after saving closes the document

  • Re: Word VBA Assistance


    Sorry Sin, I still dont understand. The code I provided will do all of this for you... You dont need to record or re-record the macro.


    Enter the code in the VBE and follow the instructions to assign a key to a macro as follows (from the Word Help file)



    Ger

    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont. :P


    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25... ;)

    _______________________________________________

  • Re: Word VBA Assistance


    By the way, 2 other things...


    1) you can assign a keyboard short cut to any menu item, font or macro that already exists.
    2) what you are trying to do in code can be done using two pre-existing MS Word keyboard short cuts CTRL + S to save the document (or save as if it hasnt already been saved) and CTRL + W to close the document. ALT + F4 closes word completely.


    Ger

    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont. :P


    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25... ;)

    _______________________________________________

  • Re: Word VBA Assistance


    Ger


    I don't know if I'm right but I think the OP wants to display the Save As dialog box to prompt for a filename.:)


    We all know how to do that in Excel - GetSaveAsFilename, but I'm unsure how it's done in Word.


    I'll just go and see if I can find out.

  • Re: Word VBA Assistance


    Quote from norie

    Ger


    I don't know if I'm right but I think the OP wants to display the Save As dialog box to prompt for a filename.:)


    correct


    i also must designate a directory which should show up in the prompt

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!