Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Save manipulated excel sheet with different name (

    I use the following code to open a .xls file:
    <pre> Dim appExcel As Excel.Application
    Set appExcel = CreateObject("Excel.Application")
    Dim strTheFile As String
    strTheFile = CurrentProject.Path & "template.xls"
    appExcel.Workbooks.Open strTheFile
    appExcel.Visible = True
    Dim strSheetName As String
    strSheetName = "DATA"
    appExcel.Sheets(strSheetName).Select


    With appExcel
    .Range("A1").Select
    .ActiveCell.Value = rstIn!fname & "'s Team"
    .Range("a2").Value = rstIn!PxWx & " 20" & rstIn!Year
    .Range("A6").Select
    End With
    </pre>



    Now, how do I save the file with a different name?
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Save manipulated excel sheet with different name (

    Add the following declaration near the beginning of your code:

    Dim wbk As Excel.Workbook

    and change the line

    appExcel.Workbooks.Open strTheFile

    to

    Set wbk = appExcel.Workbooks.Open(strTheFile)

    You can then use a line like this to save the workbook under another name:

    wbk.SaveAs CurrentProject.Path & "newname.xls"

  3. #3
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save manipulated excel sheet with different na

    Thank you so much, Hans.

    It worked perfectly.
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

Posting Permissions

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