+ Reply to Thread
Results 1 to 5 of 5

how can I add a path where to save the new workbook?

  1. #1
    Registered User
    Join Date
    09-11-2013
    Location
    zastron,south africa
    MS-Off Ver
    Excel 2010
    Posts
    48

    how can I add a path where to save the new workbook?

    Hi,
    Pls can someone help me, I need to add a code that specifies where to save my file, the path for the new workbook must be, c:\pos\supdata.range("a2").value

    Here is my code
    [CODE]Private Sub add_Click()

    Sheets("ITEMDATA").Select
    Range("A1:M25").Select
    Selection.Copy
    Sheets("SUPDATA").Select

    Windows(ActiveSheet.Range("A2").Value).Activate
    Range("a4").Select
    ActiveSheet.Paste
    Range("a4").Select
    ActiveWorkbook.Save
    ActiveWorkbook.Close
    Windows("BROKS POS.XLSM").Activate
    Sheets("SUPDATA").Select
    Range("A2:D2").ClearContents
    Sheets("ITEMDATA").Select
    Range("A2:D25").ClearContents



    Me.Hide

    End Sub[\CODE]
    Creating POS

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: how can I add a path where to save the new workbook?

    As far as I can see that code isn't creating, or saving, a new workbook.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    09-11-2013
    Location
    zastron,south africa
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: how can I add a path where to save the new workbook?

    Oops, wrong code, hetre we are

    [CODE]Private Sub CommandButton1_Click()


    Dim WS As Worksheet, lRow As Long, Str As String

    Set WS = Sheets("supdata")
    lRow = WS.Range("A" & Rows.Count).End(xlUp).Offset(1).Row

    '____error handling______


    If TextBox1.Value = "" Or nullstring Then
    MsgBox "Complete All Information!", vbCritical, "Error..."
    GoTo error1
    End If



    '____error handling end______

    If MsgBox("Add " & TextBox1.Value & " to the database?", vbYesNo, "Confirm add") = vbYes Then

    WS.Cells(lRow, "A") = TextBox1.Value
    WS.Cells(lRow, "B") = TextBox2.Value
    WS.Cells(lRow, "C") = TextBox3.Value
    WS.Cells(lRow, "D") = TextBox4.Value


    MsgBox TextBox1.Value & " has been added "
    Range("SUPDATA!A1:D2").Copy
    Workbooks.add
    Range("A1").PasteSpecial
    ActiveSheet.Name = Range("B2").Value
    ActiveWorkbook.SaveAs Filename:=Range("A2").Value

    TextBox1.Value = nullstring
    TextBox2.Value = nullstring
    TextBox3.Value = nullstring
    TextBox4.Value = nullstring

    NEWACC.Hide


    Else
    End If
    Windows("BROKS POS.XLSM").Activate
    ADDSTOCK.Show vbModeless


    error1:
    End Sub
    [\CODE]

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: how can I add a path where to save the new workbook?

    The closing code tag is [/code]
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    09-11-2013
    Location
    zastron,south africa
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: how can I add a path where to save the new workbook?

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Save a workbook to a folder path in textbox2 using textbox1 as filename
    By yoko21 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-24-2013, 03:59 AM
  2. Path name invalid when trying to save a workbook - VBA
    By Jamiec94 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-17-2013, 12:42 PM
  3. Replies: 5
    Last Post: 03-21-2013, 07:34 AM
  4. [SOLVED] Macro to get worksheets to save to new workbook with OPEN workbooks .PATH & " " as name.
    By NicksDad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2012, 08:07 PM
  5. Save Workbook using name and path in a cell
    By adinic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-11-2007, 01:27 PM

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