Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: mrako

OK.  So it will work when you change the focus away then back again.  That sounds just like what the external post talked about.  But it seems the focus change isn't happening within the code as desired, and is relying on user interaction to change the focus.  I was able to import your form, but was not able to reproduce the same results/behavior.  I can see within UserForm code, that you are attempting to immediately change the focus from the Excel application that you just started using a Shell command, to the TextBox within the form.  Then you're using GetObject to get the Excel application again, then immediately trying to set application options within it.

   When use another Module to show this form, and launch this other module as a macro, it shows the form, then waits.  When I click the CommandButton1, it instantly shows an error that says "Compile error:  Sub of Function not defined", and when I click the OK button on that error dialog, the word "Sleep" is always highlighted.  When I right click on that highlighted word "Sleep" and choose 'Definition', the pop-up says "Identifier under cursor is not recognized".  It doesn't seem to know what this is.  I know that the Sleep routine is a Windows API sub, and not a VBA sub, and so I thought you had to import or declare it within the local module before you could use it, but I could be wrong, because I don't really use it.  But if that isn't causing you any troubles, it might just be something simple like a reference I don't currently have turned on, or something similar.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)