Passing parameters to a macro

Status
Not open for further replies.

Rolf Alber

Usenet Archive
Joined
Dec 12, 2001
Messages
3
Reaction score
0
I wonder if it is possible to pass over a few parameters to a macro. According to the manual the syntax for starting a macro is:
macro <macroname> [arg1 ag2 ... argn]

So I thought arg1 to argn could be parameters that are passed over to the macro. Unfortunately it seems that my macro wont take any parameters. (the macro starts like this: Sub main (x As double) )

Any ideas ?

rolF
 
Command$ is a built-in string that contains the entire argument list. This can be parsed into words using Word$

Here is a sample macro that creates a new drawing from a seed:

' Create drawing from defined seed
Dim seedFile As String
Dim newFile As String
Dim cmdSeed As String
Dim cmdCreate As String
Dim dirName As String

Sub Main
' get file names from keyin
cmdSeed = Word$ (Command$, 1)
cmdCreate = Word$ (Command$, 2)

' expand seed name to full path and filename
If MbeFindFile(seedFile, cmdSeed, "MS_SEEDFILES", ".dgn") MBE_Success Then MbeWriteError "Can't find seed file: [" & cmdSeed & "]" Exit Sub End If

' get new file path and name (default to same dir as curr drawing) dirName = FileParse$ (MbeDgnInfo.dgnFileName, 2) newFile = dirName & "\" & cmdCreate & ".dgn"

' create file
On Error Goto ErrHandler
FileCopy seedFile, newFile
MbeWriteError "Drawing created: [" & newFile & "]"
Exit Sub

ErrHandler:
If Err = 55 Then 'File already open.
MbeMessageBox "Cannot copy an open file. Close it and try again." Else MbeMessageBox "An unspecified file copy error has occurred" End If

End Sub
 
Status
Not open for further replies.

Latest threads

Back
Top