+ Reply to Thread
Results 1 to 4 of 4

Automatic saving

  1. #1
    please help me
    Guest

    Automatic saving

    I would like to include a button on a worksheet that when clicked will save
    the worksheet as "purchase order" plus a number that is entered in a cell on
    the worksheet.

    How would I go about this?

  2. #2
    Jason Morin
    Guest

    Re: Automatic saving

    1. Copy the code below:

    Dim sPath As String
    sPath = "C:\Documents and Settings\jmorin\Desktop\"
    ActiveWorkbook.SaveAs Filename:=sPath & _
    "Purchase Order " & Range("A1").Value & ".xls"

    2. Go to View > Toolbars and select "Control Toolbox"
    3. Click on "Command Button" and draw a button on your
    worksheet.
    4. Right-click and go to "View Code".
    5. Paste in the code from step 1.
    6. Press ALT+Q to go back to Excel.
    7. Press the "Exit Design Mode" the Control Toolbox
    toolbar.

    The code is set up to look for a PO# in A1. Change the
    path to suit your needs.

    HTH
    Jason
    Atlanta, GA

    >-----Original Message-----
    >I would like to include a button on a worksheet that

    when clicked will save
    >the worksheet as "purchase order" plus a number that is

    entered in a cell on
    >the worksheet.
    >
    >How would I go about this?
    >.
    >


  3. #3
    Guest

    Automatic saving

    hi,
    Put this in the button's code module
    Sub commandbutton1_click()
    Dim n As Range
    Set n = Range("A1")
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:= _
    "H:\CodeStuff\PO" & n & ".xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:= _
    "", ReadOnlyRecommended:=False _
    , CreateBackup:=False
    Workbooks.Open Filename:="H:\CodeStuff\POtest.xls"
    ActiveWindow.ActivateNext
    ActiveWorkbook.Close
    Application.DisplayAlerts = True
    End Sub

    >-----Original Message-----
    >I would like to include a button on a worksheet that when

    clicked will save
    >the worksheet as "purchase order" plus a number that is

    entered in a cell on
    >the worksheet.
    >
    >How would I go about this?
    >.
    >


  4. #4
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    assign this macro to your button:


    ActiveWorkbook.SaveAs (["purchaseorder" & A2])
    End Sub

    assuming that A2 is the cell containing the invoice number. The brackets are required inside the parenthesis.

    HTH
    Bruce
    The older I get, the better I used to be.
    USA

+ 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