How to return data from a function written as a simplescript?
Public Function Open_Img(imgFilePath As String) As SimpleScript
Open_Img = New SimpleScript
Open_Img.SaveUndoSteps = False
Dim docList
Dim image
Dim doc
With Application.DocumentCommands.Open(Open_Img)
.Filenames = New String() {imgFilePath}
.Run(docList)
End With
With Application.DocumentCommands.ActiveImage(Open_Img)
.Run(image)
End With
With Application.DocumentCommands.Active(Open_Img)
.Run(doc)
End With
'Return doc??
'Return image??
How can I get anything out of this function?
End Function
0
Best Answer
-
In this case the variable is passed byref so it will be returned from the function.
That said, the main reason for using this syntax is to keep the code compatible with the interactive macro designer. If you are going to code your macros manually you can use a much simpler syntax without needing a SimpleScript object.Public Function GetImageDocument() As IMcDocument Dim docList1 As System.Collections.IList With Application.DocumentCommands.Open(Nothing) .Filenames = New String() {ThisApplication.Path(mcPathType.mcptSampleImages) & "Count and Size\micro_etch.tif"} .Run(docList1) End With Return docList1(0) End Function
PIerre
0
Answers