Controlling an MS Excel file

azizrasul

Well-known Member
Joined
Jul 7, 2003
Messages
1,304
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
What API code can I use to set the focus on an open MS Excel with a dialog box? I want to press Shift C to close the dialog box.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Is this for an VBA project or for a different language? ie are you running this from an Office application?

If it is an office application than you can loop through any open userforms:
VBA Code:
    Dim UForm As Object

    'Hide any open modal sheet in order to show wait form
    For Each UForm In VBA.UserForms
        If UForm.Visible = True Then
            UForm.Hide
'            Debug.Print UForm.Name
        End If
    Next
 
Upvote 0
I am running the code from an MS Access db. When the MS Excel file opens and it happens to a non activated MS Office version, the Microsoft Office Activation Wizard dialog box appears. The code in MS Access hangs until the Close button is pressed on the dialog box. Hence the requirement for a API solution.

Once the dialog box closes and the MS Excel file is closed, I can then produce a message box to say that the user does not have an official MS Office copy as normally the MS Excel file will be in invisible mode and as a genuine copy of MS Office does not produce the dialog box, then there is no problem. The above exercise places the MS Excel file in visible mode to check the existence of a genuine MS Office copy.

Hope that makes sense.
 
Upvote 0
Using GetObject doesn't work as the code still hangs. Hence the API route.
 
Upvote 0

Forum statistics

Threads
1,213,528
Messages
6,114,154
Members
448,553
Latest member
slaytonpa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top