Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command-line switches TJ Dowling Excel Discussion (Misc queries) 2 February 8th 08 04:00 PM
Command line switches - possible T1 Red Alarm Excel Discussion (Misc queries) 2 August 19th 07 08:54 AM
Command Line Export fjurek Excel Discussion (Misc queries) 6 April 23rd 07 09:08 PM
Q: command line in OE JIM.H. Excel Discussion (Misc queries) 0 May 30th 05 10:48 PM
DOS Command Line Chris Excel Programming 5 October 2nd 03 02:06 PM


All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"