Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
argument in command line
Hello, how can I make to recover an argument in command line placed to my
Excel file via VBA?? I tested the Command() function but that remains without success. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
argument in command line
Mélanie,
Found this: http://www.j-walk.com/ss/excel/eee/eee002.txt NickHK "Mélanie H." wrote in message ... Hello, how can I make to recover an argument in command line placed to my Excel file via VBA?? I tested the Command() function but that remains without success. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
argument in command line
This was posted very recently by Michael Pierron
http://www.google.fr/groups?hl=fr&lr....phx.gbl#link4 Message n° 4 de ce fil De :Michel Pierron ) Objet : Excel Start-up parms View this article only Groupes de discussion :microsoft.public.excel.programming Date :2005-02-07 04:39:00 PST Hi MrT, You can test, in ThisWorkbook module of your file: Option Explicit Private Declare Function GetCommandLine Lib "kernel32" _ Alias "GetCommandLineA" () As Long Private Declare Function lstrlen Lib "kernel32" Alias _ "lstrlenA" (ByVal lpString As Long) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias _ "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long) Private Sub Workbook_Open() Dim CmdLine$, CmdArgs$(), i&, ArgNb& CmdLine = GetCommLine If Len(CmdLine) = 0 Then Exit Sub i = InStr(1, CmdLine, ThisWorkbook.FullName, 1) If i Then CmdLine = Mid$(CmdLine, 1, i - 1) Else Exit Sub If Right$(CmdLine, 1) = """" Then i = 2 Else i = 1 CmdLine = Mid$(CmdLine, 1, Len(CmdLine) - i) CmdLine = Mid$(CmdLine, InStr(1, CmdLine, " /e", 1) + 3, Len(CmdLine)) & "/" Do Until Len(CmdLine) < 2 i = InStr(CmdLine, "/") ArgNb = ArgNb + 1 ReDim Preserve CmdArgs(1 To ArgNb) CmdArgs(ArgNb) = Mid$(CmdLine, 1, i - 1) CmdLine = Mid$(CmdLine, i + 1, Len(CmdLine)) Loop For i = 1 To ArgNb CmdLine = CmdLine & "Parameter " & i & ": " & CmdArgs(i) & vbLf Next i MsgBox CmdLine End Sub Private Function GetCommLine() As String Dim Ret&, sLen&, Buffer$ Ret = GetCommandLine sLen = lstrlen(Ret) If sLen Then GetCommLine = Space$(sLen) CopyMemory ByVal GetCommLine, ByVal Ret, sLen End If End Function Examples of use: Execute dialog box: excel /eInfo1/Info2 c:\your file.xls with short cut: "C:\Program Files\Microsoft Office\Office10\EXCEL.EXE" /eInfo1/Info2 "c:\your file.xls" with batch file: Start "C:\Program Files\Microsoft Office\Office10\EXCEL.EXE" /eInfo1/Info2 "c:\your file.xls" Regards, MP -- Regards, Tom Oglvy "Mélanie H." wrote in message ... Hello, how can I make to recover an argument in command line placed to my Excel file via VBA?? I tested the Command() function but that remains without success. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Command-line switches | Excel Discussion (Misc queries) | |||
Command line switches - possible | Excel Discussion (Misc queries) | |||
Command Line Export | Excel Discussion (Misc queries) | |||
Q: command line in OE | Excel Discussion (Misc queries) | |||
DOS Command Line | Excel Programming |