Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MrT MrT is offline
external usenet poster
 
Posts: 1
Default Excel Start-up parms

Does anyone know how to execute Excel and send it a value... then use
the value in a VBA macro in Excel? This would be something like a "run"
command with parms.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Excel Start-up parms

You can't pass custom command line parameters to Excel. The
closest you can come is to create a put the code you want to
execute in the Workbook_Open event procedure in the ThisWorkbook
code module. This procedure will be executed when the workbook
is opened.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"MrT" wrote in message
oups.com...
Does anyone know how to execute Excel and send it a value...
then use
the value in a VBA macro in Excel? This would be something like
a "run"
command with parms.



  #3   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 594
Default Excel Start-up parms

One thing you can do is to open Excel, and then under macro control, have it
open a second workbook, and perform macro commands thereto........

Vaya con Dios,
Chuck, CABGx3



"MrT" wrote in message
oups.com...
Does anyone know how to execute Excel and send it a value... then use
the value in a VBA macro in Excel? This would be something like a "run"
command with parms.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Excel Start-up parms

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

"MrT" a écrit dans le message de
oups.com...
Does anyone know how to execute Excel and send it a value... then use
the value in a VBA macro in Excel? This would be something like a "run"
command with parms.


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
OT :Start your own online business today !start making dollars [email protected] Excel Discussion (Misc queries) 0 May 6th 06 09:29 PM
I've never used Excel-where do I start? Cap Rate Excel Discussion (Misc queries) 3 April 3rd 06 01:48 PM
bd start, excel 97 zorro9 Excel Discussion (Misc queries) 0 February 17th 06 02:07 AM
Start spreadsheet with WinXP start Gordon Gradwell Excel Worksheet Functions 1 July 13th 05 11:35 AM
Can't see macros with parms in Tools -- Macros Peter Chatterton Excel Programming 3 September 7th 04 03:05 PM


All times are GMT +1. The time now is 09:25 AM.

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

About Us

"It's about Microsoft Excel"