Sorry, Lasse, I am not an expert programmer. But I think, from reading the
help files, that a procedure is not a macro unless it has no arguments. So
there is no way to pass parameters directly to a macro. There might be a
workaround or some other way to get the job done indirectly. Or maybe there
is a way to run a non-macro procedure (one that has arguments). Your code
looks as if it should work, but only if PMNAutoSaveBefore() would be a
macro. I'm guessing that PMNAutoSaveBefore doesn't run when you execute
your code, and that would be because it isn't part of the VBAMembers
collection. If, in Inventor, you go to Tools > Macro > Macros, it will show
the members of that collection, and you will know for sure. But I don't
have any ideas for workarounds.
--
Sam Bixler
Eli Lilly and Company, Indianapolis
Post by Lasse FrederiksenKent answer didn't run a specific macro, it only loaded the default.ivb...
The macro in default.ivb i'm trying to run is named
Public Sub PMNAutoSaveBefore(oName as String)
Private Sub oRunAutoMacro()
Dim oVBA As InventorVBAProjects
Set oVBA = oApp.VBAProjects
Dim oVBAProject As InventorVBAProject
Dim oVBAComponent As InventorVBAComponent
Dim oVBAMember As InventorVBAMember
For Each oVBAProject In oVBA
If oVBAProject.Name = "ApplicationProject" Then
For Each oVBAComponent In oVBAProject.InventorVBAComponents
If oVBAComponent.Name = "AutoMacros" Then
For Each oVBAMember In
oVBAComponent.InventorVBAMembers
Post by Lasse FrederiksenIf oVBAMember.Name = "PMNAutoSaveBefore" Then
oVBAMember.Execute
Exit For
End If
Next
Exit For
End If
Next
Exit For
End If
Next
End Sub
I would just like a direct way to run this macro, and maby a way to pass the
oName to the macro..
Lasse
Post by Sam BixlerKent Keller answered this question for me in a thread entitled "default VBA
project isn't loaded -- IV9 SP1" dated 10/15/04. But you won't be able to
pass a parameter directly to a macro. Macros, by definition, have no
arguments. There's probably some way around that limitation, but I don't
know what it would be. In my case, my one parameter could have three
different values, so I simply made three different macros which do nothing
but call the main procedure with one of those values as an argument.
Hope this is useful.
--
Sam Bixler
Eli Lilly and Company, Indianapolis
Post by Lasse FrederiksenSimple question... How do I do that... I would like to pass a parameter
too,