+ Reply to Thread
Results 1 to 4 of 4

Save As code in path from a cell or textbox1

Hybrid View

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

    Red face Save As code in path from a cell or textbox1

    Hi Guys,

    I need a vba code to "save as" a workbook.xlsm into .xlsx.

    I used the following code but its not working

       ActiveWorkbook.SaveAs FileName:=Workbooks("Test1.xlsm").Sheets("hello").Range("C3").Value & "\" & Workbooks("Test1.xlsm").Sheets("hello").Range("C2").Value & "_TestSave.xls" _
            , FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
            ReadOnlyRecommended:=False, CreateBackup:=False
    Cell C3 has the folder path which is linked to textbox1 as defined by the user. Cell C2 has the file name which is linked to textbox2 as defined by the user. I also want to include "TodaysDate" at the end of the filename.

    Thanks.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Save As code in path from a cell or textbox1

       
    FName=Workbooks("Test1.xlsm").Sheets("hello").Range("C3").Value & "\" & Workbooks("Test1.xlsm").Sheets("hello").Range("C2").Value & "_TestSave.xls"
    msgbox Fname ' check if the name is correct
    ActiveWorkbook.SaveAs FileName:=Fname, FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
            ReadOnlyRecommended:=False, CreateBackup:=False
    If solved remember to mark Thread as solved

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Save As code in path from a cell or textbox1

    Hi, yoko21,

    maybe try
    With Workbooks("Test1.xlsm").Sheets("hello")
       ActiveWorkbook.SaveAs Filename:=.Range("C3").Value & "\" & .Range("C2").Value & "_TestSave_" & Format(Date, "YYMMDD") & ".xlsx", _
            FileFormat:=xlOpenXMLWorkbook, Password:="", WriteResPassword:="", _
            ReadOnlyRecommended:=False, CreateBackup:=False
    End With
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

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

    Re: Save As code in path from a cell or textbox1

    Quote Originally Posted by HaHoBe View Post
    Hi, yoko21,

    maybe try
    With Workbooks("Test1.xlsm").Sheets("hello")
       ActiveWorkbook.SaveAs Filename:=.Range("C3").Value & "\" & .Range("C2").Value & "_TestSave_" & Format(Date, "YYMMDD") & ".xlsx", _
            FileFormat:=xlOpenXMLWorkbook, Password:="", WriteResPassword:="", _
            ReadOnlyRecommended:=False, CreateBackup:=False
    End With
    Ciao,
    Holger
    Perfect!!! Thanks. solved!

+ 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. If textbox1 is empty then put paste some default text to textbox1
    By vijaynadiad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2013, 03:16 PM
  3. Code that generates a unique save path base on specific user
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2013, 08:54 AM
  4. save the image path in the cell
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2012, 07:39 AM
  5. Save as cell with path
    By Curben in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2006, 08:39 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