Results 1 to 2 of 2

Thread: Save a Formatted Excel Form to a new Directory

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Location
    ny,ny
    Posts
    1

    Post

    I COULD REALLY USE HELP ON THIS ONE - THANK YOU!!!
    I need to access a formatted Excel form, copy it,
    add some cell values and then resave it in it's new directory.
    Seems simple enough..........
    However, I have only managed to save either empty Excel references to the directory, or the Form's values only without any of the formatting. The code goes basically
    something like this:

    dim ORGBook as excel.workbook
    dim HDCBook as excel.workbook

    set ORGBook = getobject("c:\Docs\STP\X.xls")
    ORGbook.SaveAs "c:\Output\STP\NewX.xls
    set HDCBook = getobject("c:\Output\STP\NewX.xls")
    'Fill certain fields
    'then resave and close


    The problem is with the ORGbook.saveas statement. It is saving an empty reference - NO DOCUMENT ????????

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post


    I COULD REALLY USE HELP ON THIS ONE - THANK YOU!!!
    I need to access a formatted Excel form, copy it,
    add some cell values and then resave it in it's new directory.
    Seems simple enough..........
    However, I have only managed to save either empty Excel references to the directory, or the Form's values only without any of the formatting. The code goes basically
    something like this:

    dim ORGBook as excel.workbook
    dim HDCBook as excel.workbook

    set ORGBook = getobject("c:\Docs\STP\X.xls")
    ORGbook.SaveAs "c:\Output\STP\NewX.xls
    set HDCBook = getobject("c:\Output\STP\NewX.xls")
    'Fill certain fields
    'then resave and close


    The problem is with the ORGbook.saveas statement. It is saving an empty reference - NO DOCUMENT ????????
    I generally open an instance of Excel:

    Code:
    dim MyXL as Excel.Application
    
    set MyXL = New Excel.Application
    Then I'd do the rest
    Code:
    Dim ORGBook as Excel.Workbook
    Dim HDCBook as Excel.Workbook
    
    set ORGBook = MyXL.Workbooks.Open("c:\Docs\STP\X.xls")
    MyXL.ORGbook.SaveAs "c:\Output\STP\NewX.xls"
    set HDCBook = MyXL.Workbooks.Open("c:\Output\STP\NewX.xls")
    'Fill certain fields 
    'then resave and close
    
    MyXL.HDCbook.Close SaveChanges:=True
    MyXL.Quit

Posting Permissions

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



Click Here to Expand Forum to Full Width