Can anybody help???
All I need is a macro to demonstrate how to use the "OnFileNew" command.
If the inventor user selects "File New", all I need is a macro that shows a message box saying "HELLO".
Obviously this message box is to just notify me that the macro is working. I will modify the msgbox "HELLO" command
to siut myself. I just do not know how to implement this inside a macro
Thanks in advance!!!
Place this in a Class Module Named "FileNewDialog"
Option Explicit
Private WithEvents oFileUIEvents As FileUIEvents
Private Sub Class_Initialize()
Set oFileUIEvents = ThisApplication.FileUIEvents
End Sub
Private Sub Class_Terminate()
Set oFileUIEvents = Nothing
End Sub
Public Sub oFileUIEvents_OnFileNewDialog(ByVal TemplateDir As String, ByVal ParentHWND As Long, TemplateFileName As String, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)
If HandlingCode = kEventNotHandled Then
MsgBox ("HELLO")
End If
End Sub
Place the following in any Module
Dim oEventHandler As FileNewDialog Private Sub DetectFileNew_On() Set oEventHandler = New FileNewDialog End Sub Private Sub DetectFileNew_Off() Set oEventHandler = Nothing End Sub
And then run the Macro "DetectFileNew_On"
After that you do a file new and watch it catch the event, simple eh?
Hi,
Thanks for the reply.
I have changed the class module thus:
MsgBox "HELLO"
HandlingCode = kEventCanceled
Is it possible, in the class module , to replace MsgBox "HELLO"?
Instead of the MsgBox, I want to run an "exe" file say (for example only) notepad, then wait until it is closed before continuing, without showing the "New file dalog box"?
Many thanks!!!
Hi,
no. the other EXE is within the other process and the Inventor event fires the events of Inventor process. If you just need some user input, why you did not add a dialog (with the text box)? i.e.
public Sub oFileUIEvents_OnFileNewDialog
' MyDialog is added in your program project
Dim oMyDialog As MyDialog
mMyDialog.ShowDialog
' m_userinput is a string defined in the dialog. It is the vaue of the text box
'wait for use input
Dim oUserInput As String
oUserInput = mMyDialog.m_userinput
End Sub
Hi,
Can I please, quickly, enquire how easy it would be to convert the above into a VB.Net project.
Regards
Darren