+ Reply to Thread
Results 1 to 2 of 2

save workbook as different name

Hybrid View

  1. #1
    Damien
    Guest

    save workbook as different name

    Hi all,
    I need to be able to save the active workbook by including the name which
    appears in a combo box on the users sheet into the file Path/Name. I can save
    the file by having a complete Path/Name but need to be able to concatenate
    the selection with the given path.
    The following code returns an 'object required' error.
    Can anyone help? D

    Sub SaveFile()
    Dim fs As Object
    Dim strFile As String
    Dim strNewFile As String
    Dim FilePath As String

    Set FilePath = ("\\Blah Blah Blah\")
    strFile = ThisWorkbook.Name
    strNewFile = "\\Blah Blah Blah\" & cboxProjectList.Value & "\.xls"

    Set fs = CreateObject("Scripting.FileSystemObject")
    fs.CopyFile strFile, strNewFile
    MsgBox "Your file has been saved"

    End Sub

  2. #2
    Kevin McCartney
    Guest

    RE: save workbook as different name

    Hi Damien

    Try using

    application.ActiveWorkbook.SaveAs filename, fileformat etc. etc.

    see help and exmaple for SaveAs

    HTH
    KM


    "Damien" wrote:

    > Hi all,
    > I need to be able to save the active workbook by including the name which
    > appears in a combo box on the users sheet into the file Path/Name. I can save
    > the file by having a complete Path/Name but need to be able to concatenate
    > the selection with the given path.
    > The following code returns an 'object required' error.
    > Can anyone help? D
    >
    > Sub SaveFile()
    > Dim fs As Object
    > Dim strFile As String
    > Dim strNewFile As String
    > Dim FilePath As String
    >
    > Set FilePath = ("\\Blah Blah Blah\")
    > strFile = ThisWorkbook.Name
    > strNewFile = "\\Blah Blah Blah\" & cboxProjectList.Value & "\.xls"
    >
    > Set fs = CreateObject("Scripting.FileSystemObject")
    > fs.CopyFile strFile, strNewFile
    > MsgBox "Your file has been saved"
    >
    > End Sub


+ 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