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

[475 byte] By [dustinto] at [2007-12-23]
# 1

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

DMan1 at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 2

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?

dustinto at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 3

'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

dustinto at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 4
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

DMan1 at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 5
I don't think it is a VBA since this is part of a another application. But I don't know.
dustinto at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...