Dialog box will not show when overriding Built-in Word 2007 macro

D

dvdastor

Hi All,

I've been playing with this for a few days now and hope to get some
help on the matter..

All I need to do is to determine if a user has clicked the "OK" box on
the Compatibility Checker dialog box. By looking through Word's
macros I found this dialog is displayed through the CompatChkr Sub. I
created my own macro in the document with the same name as such:
---------------------
Sub CompatChkr()

Application.Dialogs(wdDialogCompatibilityChecker).Display

bCompat = True

End Sub
-------------------------

The document is being launched via a .NET app using the
Application.Documents.Open method with all default options for that
method. However, when the Prepare -> Compatibility Checker button is
pressed, the macro is triggered but no dialog is displayed. It steps
through it just like it should, but the .display is not fired.

Here is the mystery...if I open the document via the file sytem, by
just double clicking the .docx file and do the same action, my macro
is triggered and the dialog IS displayed.

Futher mystery... I refined the overridden macro to see if it could
display any dialogs and lo and behold it could.

---------------------
Sub CompatChkr()

'Just testing to see if any dialogs open....
Application.Dialogs(wdDialogFilePrint).Display

Application.Dialogs(wdDialogCompatibilityChecker).Display

bCompat = True

End Sub
-------------------------

In this case, the macro is hit and upon pressing the Prepare ->
Compatibility Checker button, the File Print dialog appears but
nothing happens after that dialog is dismissed. The Compat checker
never shows.

What would be the difference in opening via a .NET application or
double clicking and opening via the file system??

Can anyone shed some light on this??

Thanks in advance!
David
 
R

Russ

If you go into Word VBA editor and open up the object browser and search for
wddialog, you see a list of those dialogs. In my MacWord, I don't see a
wdDialogCompatibilityChecker in that list.

If you record a macro in Word while using that dialog, do you get any useful
code?
 
E

Ed

Hi David (& Russ),

(Russ, it's a Word 2007 thing.)

David, don't think this will help much but it looks like the issue isn't
confined to .NET.

I tried a simple VBScript (and a VB6 program) and got the same effect - if
Word was invoked programmatically, that dialog didn't seem to want to play,
regardless of whether I over-rode the built-in command or just executed a
test macro to display the dialog. (Although I could still invoke the dialog
through the Office button if I wasn't over-riding it with a macro.)

The script was
------------------------------------------------------------
Set WordApp = CreateObject("Word.Application")

WordApp.Visible = True

WordApp.Documents.Add
------------------------------------------------------------

If I changed the script to use "GetObject(,"Word.Application")", started
Word manually and then ran the script I was able to display the dialog by
means of a macro (macro-matically?). Not much use in those situations where
Word's not already open.

Cheers.

Ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top