Hi everyone:

I'm calling an Excel file from C#; now, because I Want to run automatically a Macro, I've added to my Workbook code, Private Sub Workbook_Open() the name of the routine I want VBA to execute as soon as the file is open.

The problem is that C# is about to copy the data into the main Spreadsheet but VBA keeps running before all my data has been copied....

I've tried, loops, selecting one cell and make a loop until the last data is <>"" in order to keep running the program; pausing the VBA code for a couple of seconds but nothing seems to work....

I don't know if C# will pause until the VBA code finish executing and then continues...

Or is there a way to create a break of the code for a couple of seconds and then resume the Macro?

Any suggestions? Is there a way to call a Macro from C#? So that I could copy all the data and then call the Macro from C#?

Thanks

Carlos

Cheers!

Sorry for the late response but I've been a little busy.....

It worked! :cool:

Thank you very much

Carlos

Of course you can call macro's from c#

http://support.microsoft.com/kb/306683

That is a word example, you'll just need to use excel automation instead

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.