Excel Command Line Parameters

Jock

New member
Joined
Mar 6, 2006
Messages
2
Programming Experience
3-5
Hey all,

New to VB.Net, so bear with me! Please!

Anyway, I've managed to launch Excel using System.Start.Process("Excel", "") (or some call along those lines!).

However, when supplying the filename to open, if it contains any spaces it fails, obviously attempting to load multiple file names, split by the location of the spaces.

Does anybody know of a way round this? (for example, my spreadsheet would be 'C:\My Documents\Spreadsheet 1.xls")

Cheers,
Greg
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,605
Location
Norway
Programming Experience
10+
enclose the filename in quotes, if this is the commandline:
VB.NET:
Excel.exe "k:\bok 1.xls"
then this is how to do it in code, doubleqoute any enclosed quotes:
VB.NET:
Process.Start("Excel.exe", """k:\bok 1.xls""")
 

Jock

New member
Joined
Mar 6, 2006
Messages
2
Programming Experience
3-5
JohnH,

Thanks for that - had tried the \" having come for a C++ background. Must try harder with thinking about differences for VB and C++. :eek:)

Thanks again...
 
Top Bottom