Get focus back on Inventor with VBA

Get focus back on Inventor with VBA

Anonymous
Not applicable
679 Views
4 Replies
Message 1 of 5

Get focus back on Inventor with VBA

Anonymous
Not applicable

I've created a VBA macro that is initiated from Inventor.  The macro calls for a FileMaker script to be run on the user's machine.

 

After the FileMaker script runs, Inventor gets the result and then displays a dialog box where the user selects "yes" or "no".  

 

I can't seem to get the focus back onto Inventor after that script runs without manually clicking back into the Inventor window (focus stays with FileMaker after the script runs).  I'd like to be able to hit "enter" to automatically select "yes" on the dialog box, but I have to get focus back on the Inventor window for that to happen.

 

Anyone know how to get VBA to steal focus back to Inventor?

 

 

Windows 10 Pro

VBA 7.1

Inventor 2017

FileMaker Pro 16

0 Likes
680 Views
4 Replies
Replies (4)
Message 2 of 5

Mark.Lancaster
Consultant
Consultant

@Anonymous

 

Programming questions and needs should be posted in the Inventor Customization forum https://forums.autodesk.com/t5/inventor-customization/bd-p/120 for best results.  I will have the moderator relocate it there to better suit your needs.

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

Message 3 of 5

bradeneuropeArthur
Mentor
Mentor
This dialog box is a userform?
Than you need to use showdialog instead of show.
Regards

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 5

Anonymous
Not applicable

Not sure I'm quite with you yet...

 

Yes, I've got a userform generated through VBA in Inventor.  It's just a yes/no msgbox.

 

But an entirely different program (FileMaker) seems to take the focus and won't give it back.

 

Here are the two relevant lines of my code.  The first calls the FileMaker program.  The second generates the msgbox in Inventor.

 

***

FMApp.Documents("AH.fmp12").DoFMScript ("InventorRevQuery")

ReadyToRelease = MsgBox("Preparing to release revision '-' of " & PartNumber & "." & vbNewLine & "Do you wish to proceed?", vbYesNo + vbExclamation, "Ready to Release?")

***

 

Having VBA generate the msgbox doesn't steal the focus back from FileMaker.  Is there VBA code that will do that?

0 Likes
Message 5 of 5

bradeneuropeArthur
Mentor
Mentor

Then Create your own defined messagebox.

please find attached the VBA Code.

Create a UserformX

and a ModuleX

'The Code For the UserFormX
Private Sub CommandButtonNo_Click()

MsgBox "Do This When NO"
UserFormX.Hide
End Sub

Private Sub CommandButtonYes_Click()

MsgBox "Do This When Yes"
UserFormX.Hide
End Sub

'The Code For the ModuleX

Public Sub main()

UserFormX.Label1.Caption = "Preparing to release revision '-' of " & PartNumber & "." & vbNewLine & "Do you wish to proceed?"

UserFormX.Show (Modal)

End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes