+ Reply to Thread
Results 1 to 8 of 8

VB button & code to save workbook

  1. #1
    Registered User
    Join Date
    02-25-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    79

    VB button & code to save workbook

    I am trying to make a invoice for work , I have a couple of bits i will try and explain that require a vb code. I don't know to much about VB and would not know where to start. Could someone please help me with this.


    I have inserted the workbook. I am wanting to make an invoice. In D5 i have a drop downlist with a list of names and a save button. I would like to find a code that when i click the save button it would automatically save the entire workbook to a directory on my server "\\server\invoices\" The name of the saved file would be the name that's in cell D5 from the drop down list.

    When the save button is clicked i would like it not only to save the workbook but to close it but not save the original file, so the next person that opens it gets a clean invoice.

    One last thing on the saved workbook i would like the macros to be disabled so no-one can change any info or click save again etc.
    Attached Files Attached Files

  2. #2
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: VB button & code to save workbook

    Well, going off of the macro recorder, I can answer a couple of those questions.

    Please Login or Register  to view this content.
    That'll save the code under the name of whatever's in cell 5, 4, aka D5. And it'll delete the button which is on page 1.

    I'm not sure about closing a workbook with a macro, never tried to do that before.

    Hope this helps.

    mew!
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  3. #3
    Registered User
    Join Date
    06-05-2008
    Posts
    84

    Re: VB button & code to save workbook

    Give this a try and see if this is what your talking about


    Change the code in Red to your file path (where you want the file saved)
    Please Login or Register  to view this content.


    Thanks, J

  4. #4
    Registered User
    Join Date
    06-05-2008
    Posts
    84

    Re: VB button & code to save workbook

    The macro above only closes the workbook

    This will exit the entire application.

    Replace
    Please Login or Register  to view this content.
    With
    Please Login or Register  to view this content.
    And you should be good to go.

  5. #5
    Registered User
    Join Date
    02-25-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: VB button & code to save workbook

    Quote Originally Posted by Slomaro2000 View Post
    Give this a try and see if this is what your talking about


    Change the code in Red to your file path (where you want the file saved)
    Please Login or Register  to view this content.


    Thanks, J

    Thanks for the quick reply, i have used this code and added application.quit as suggested by Slomaro2000. It seems to work ok but when i go into the saved file the save button still works could i disable this on the saved workbook?

    I am also thinking of adding an increment number to the invoice, i would like this still to work on the original file so it goes up one each time.

    Sorry guys its starting to sound like a mission. Thanks for your help so far

  6. #6
    Registered User
    Join Date
    02-25-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: VB button & code to save workbook

    Sorry just incase anyone missed it, could anyone help here?

  7. #7
    Registered User
    Join Date
    02-25-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: VB button & code to save workbook

    Is there anyone outthere who could point me in the right direction to solve this?

  8. #8
    Registered User
    Join Date
    02-25-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: VB button & code to save workbook

    bump...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1