+ Reply to Thread
Results 1 to 7 of 7

Save a workbook to a folder path in textbox2 using textbox1 as filename

Hybrid View

  1. #1
    Registered User
    Join Date
    09-23-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    33

    Talking Save a workbook to a folder path in textbox2 using textbox1 as filename

    Hi Guys,

    I have a deadline and I really need your help!!

    My userform1 has two textbox. Texbox1 is where the user put's his/her name, and textbox2 is where the user put/browse the folder path where to save the newly generated workbook. I want the new workbook to be saved in the path defined by the user in textbox2 with filename sequence (Textbox1_Accounting_Todaysdate) and with file extension of only .xls and .xlsx.

    VBA code for the "Browse" button which returns the folder path in textbox2:

    Private Sub Browsebutton_Click()
    Dim pathSelected As String
    
    Dim ShellApp As Object
    Set ShellApp = CreateObject("Shell.Application"). _
    BrowseForFolder(0, "Choose a folder", 0, OpenAt)
    pathSelected = ShellApp.Self.Path
    Me.output.Text = pathSelected
    Set ShellApp = Nothing
    Exit_CommandButton1_Click:
    
    Exit Sub
    
    Err_CommandButton1_Click:
    
    MsgBox Err.Description
    
    Resume Exit_CommandButton1_Click:
    
    End Sub.

    I am not really sure what to put in "Submit" button.

    For now my submit button have this:

    Private Sub Submit_Click()
    
    Workbooks.Add
    
    (and a bunch of VBA code for accounting)
    
    (VBA to save???) 
       
    End Sub
    Thanks
    sorry for my bad english

    Moderator Note:

    Pls use code tags around your code next time as per forum rules.
    Last edited by Fotis1991; 09-23-2013 at 11:49 AM.

  2. #2
    Registered User
    Join Date
    09-23-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    33

    re: Save a workbook to a folder path in textbox2 using textbox1 as filename

    help please.

  3. #3
    Registered User
    Join Date
    09-23-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    33

    re: Save a workbook to a folder path in textbox2 using textbox1 as filename

    no one? please anyone?

  4. #4
    Registered User
    Join Date
    02-14-2013
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Save a workbook to a folder path in textbox2 using textbox1 as filename

    Try:

    Private Sub Submit_Click()
    
    Dim wkbNew As Workbook
    Set wkbNew = Workbooks.Add
    
    (and a bunch of VBA code for accounting)
    
    wkbNew.SaveAs textbox2.value & "\" & textbox1.value & "_Accounting_" & Format(Now, "ddmmyyyy") & ".xls"
       
    End Sub

  5. #5
    Registered User
    Join Date
    09-23-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Save a workbook to a folder path in textbox2 using textbox1 as filename

    Quote Originally Posted by frostnl View Post
    Try:

    Private Sub Submit_Click()
    
    Dim wkbNew As Workbook
    Set wkbNew = Workbooks.Add
    
    (and a bunch of VBA code for accounting)
    
    wkbNew.SaveAs textbox2.value & "\" & textbox1.value & "_Accounting_" & Format(Now, "ddmmyyyy") & ".xls"
       
    End Sub
    Worked Perfectly!!!!! Thanks!!

  6. #6
    Registered User
    Join Date
    09-23-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Save a workbook to a folder path in textbox2 using textbox1 as filename

    now how do I mark this thread as [solved]?

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Save a workbook to a folder path in textbox2 using textbox1 as filename

    As that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED,as per Forum Rule #9. Thank you.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ 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] Is there a way of gettting the path of a filename in any folder
    By all4excel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-28-2021, 09:53 PM
  2. [SOLVED] Cell Value = TextBox1.Value + TextBox2.Value
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2013, 09:30 AM
  3. [SOLVED] textbox1 * textbox2 = textbox3
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-23-2012, 03:35 PM
  4. Choose 4 Random Numbers if they are not textbox1 or textbox2
    By blitz74 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-03-2012, 02:41 AM
  5. [SOLVED] TextBox1 = TextBox2
    By Anto_BT in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2012, 03:34 AM

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