Copy an Excel File and Update some of it's cells

I am adding this to my app that I made yesterday that creates new project folders and copies files over.

Now I would like to beable to edit the excel files as I copy them over. I have started to play around with the excel stuff for VB and I got it to create a new file, but I need help on editing it as I copy it. Ideally I would like to be able to only change some cells. Like tell it to delete everything in one cell and replace it with something.

Thanks




Answer this question

Copy an Excel File and Update some of it's cells

  • sam1996

    I don't think it is a VBA since this is part of a another application. But I don't know.


  • Simmy7

    dustinto wrote:

    If I had to use those functions...

    Im thinking more like...

    Copy File (Already doing that)

    Open Excel File - At new location

    Make Changes

    Save File

    Would that work

    Yes...that will work....

    Just as a note...You are using Visual Basic for Applications which is not the same as Visual Basic .NET, for futher help regarding VBA please see the following forum:

    http://forums.microsoft.com/MSDN/ShowForum.aspx ForumID=74&SiteID=1

    Moving this thread to the VBA forum



  • walter_verhoeven

    'OPEN THE EXCEL FILE
    Dim wb As Excel.Workbook = _
    ThisApplication.Workbooks.Open("C:\YourPath\YourWorkbook.xls")

    'SELECT MY WORKSHEET
    'ThisApplication.ActiveWorkbook.Sheets(1).Select()

    Dim xlws As Excel.Worksheet = ThisApplication.ActiveWorkbook.Sheets(1).Select()


    'Edit WORKSHEET

    xlws.Cells(A, 1) = "TEXT HERE"


    'SAVE THE EXCEL FILES (ALL OPEN WORKBOOKS)
    Dim wb As Excel.Workbook
    For Each wb in ThisApplication.Workbooks
    wb.Save
    Next wb



  • NextCodec

    If I had to use those functions...

    Im thinking more like...

    Copy File (Already doing that)

    Open Excel File - At new location

    Make Changes

    Save File

    Would that work



  • Caml01

    The logic of your operation:

    Open Excel File

    Make Changes

    Save File

    Copy FIle

    ...

    Try it out in code and post back the code you are having issues with



  • Copy an Excel File and Update some of it's cells