Open .csv file and run a macro?????

M

mm

I need to run a macro on a .csv file.

Presently I open the .csv file, then run the macro.

Is there a command line switch that I can use to open the .csv file in excel
and execute a macro?

- Thanks in advance - Mike
 
D

Don Guillett

I did one for a customer recently where I used

Workbooks.OpenText Filename:=ActiveWorkbook.Path & "\" & [wbtoget]
'where wbtoget was a named cell with the name of the .csv file to get.
my other code
ActiveWindow.Close
 
M

mm

Thanks but let me clarify:

I need to automate the process of opening a .csv file AND executing a macro
all from a DOS batch file (or shortcut .lnk file)

- Mike



Don Guillett said:
I did one for a customer recently where I used

Workbooks.OpenText Filename:=ActiveWorkbook.Path & "\" & [wbtoget]
'where wbtoget was a named cell with the name of the .csv file to get.
my other code
ActiveWindow.Close

--
Don Guillett
SalesAid Software
(e-mail address removed)
I need to run a macro on a .csv file.

Presently I open the .csv file, then run the macro.

Is there a command line switch that I can use to open the .csv file in excel
and execute a macro?

- Thanks in advance - Mike
 
P

PV

try this one

Workbooks.OpenText FileName:= _
myfile, _
Origin:=xlMSDOS, StartRow:=1,
DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True,
Tab:=False, Semicolon:=True, _
Comma:=False, Space:=False, Other:=True,
OtherChar:=";"
 
D

Dave Peterson

Create a new workbook.

Record a macro when you import your .csv file.

Change the name of the macro to Auto_Open.

Save your workbook.

Close excel.

Create a shortcut to that workbook.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top