vb to automate some excel operations, please help me get started.

fftw_ayi

New member
Joined
Feb 27, 2009
Messages
2
Programming Experience
3-5
Hello, I'm a first timer to the forum with very limited knowledge of VB. I hope this is the correct forum for what I need to do.

I tried searching for some basic tutorial but I just can't seem to get going. So I was wondering if I can request someone to write a quick VB code that is a simpler version of what I will eventually need to do. Once I have that I should be able to research what I need and expand.

When this is all done, I expect to be able to type in a command in a DOS window and execute what I wrote.

So here is a simple task I would want this command to do.

In directory c:\source\, there will be a file called sourcefile.xls. On sheet1 of that file cell A1 will have the text value "A" in it.

I want to replace "A" with "B" and save the file as targetfile.xls under c:\target\

I have Visual Studio 2008 and Excel 2003... if this matters.
 
Any takers on this? I'm trying to find examples online and the ones that I do find, I get errors and being a total beginner, I have no idea what to fix.

If the example I gave above is too openned ended or doesn't make sense, please let me know.

I've used Microsoft.Office.Interop.Excel so I have a basic understanding of how to work with the excel object model, but I don't know how to set up a Console Application.

Would it help if I get into more detail about what I need to do? I didn't want to get too lengthy in my post, but I will if that will prompt someone to jump in.
 
You should be able to setup a console application by going File, New, Project, selecting Console application under VB.NET, naming it appropriately and pressing OK.

I'm not sure exactly what you are asking, but it sounds like you want to access command line parameters for your console app, so...

Depending on what version of .NET you are developing for, you can access the command line arguments in My.Application.CommandLineArgs for .NET 3.5 or using the (Microsoft.VisualBasic.Interaction.)Command function in earlier versions. (I think there is another way of accessing it as well - the old VisualBasic compatibility function is probably deprecated).

Either way, you'll probably need to parse the commandline arguments to some degree, unless you know for sure exactly what is going in and where.

By the way, expect Office Automation to be extremely slow - it can be like watching paint dry if you are getting it to do a lot.
 
Back
Top