Consulting

Results 1 to 4 of 4

Thread: Save As Location

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Save As Location

    I am creating a way for my users to send a 2007 file format to people and it will send it as a 2003 format. I am doing this because some people here are not that good with computers so I am making it as easy as possible. Here is the code I am using:

    [VBA]Set wbToEmail = ActiveWorkbook
    If frmEmailWork.cbSendInOldFormat Then
    wbToEmail.SaveAs wbToEmail.Name & ".xls", FileFormat:=xlNormal
    Else
    wbToEmail.SaveAs wbToEmail.Name
    End If[/VBA]

    The only trouble I am having is I can't figure out how to set the saveAs location and how do I remove the .xlsx from the file name?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Set wbToEmail = ActiveWorkbook
    If frmEmailWork.cbSendInOldFormat Then
    wbToEmail.SaveAs "C:\path\subpath\" & wbToEmail.Name & ".xls", FileFormat:=xlExcel8
    Else
    wbToEmail.Save
    End If
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Thanks Xld,

    That works perfectly but is there a way to remove .xlsx or .xlsm before it saves right now I am getting a file name like this "SalesReport.xlsx.xls"

    Daniel

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Really? So it doesn't work perfectly

    How about this

    [vba]

    Set wbToEmail = ActiveWorkbook
    If frmEmailWork.cbSendInOldFormat Then
    Filename = wbToEmail.Name
    Pos = InStrRev(Filename, ".")
    If Pos > 0 Then
    Filename = Left$(Filename, Pos - 1)
    End If
    wbToEmail.SaveAs "C:\path\subpath\" & Filename & ".xls", FileFormat:=xlExcel8
    Else
    wbToEmail.Save
    End If
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •