VBA: Suppress macro warnings?

  • Hi, I have an application, that opens Word and embeds an Excel.Sheet object in the page. It does this by doing the following call:

    objWordInlineShape = objWordDocument.Range(nStart).InlineShapes.AddOLEObject("Excel.Sheet.8", strExcelFileName)

    However, the Excel file contains macro's and I get a warning message about this (which I obviously don't want :)).

    Now, I know there is a DisplayAlerts property in the Excel Application object, but I don't have an Application object before calling AddOLEObject. And I cannot seem to first create the inlineshape (empty Workbook object), then get the Application object through it, set the DisplayAlerts property and only then opening the file.

    Of course, I could disable the warning message in Excel, but I'd rather not.

    Does anyone have any suggestions to suppress these warning messages programmatticaly?

    I would like to use an embedded Excel object, because that way I can scale the Excel document to the page width.

  • I *think* you can just make that doc a template (DOT) and you won't get the message. Certain versions of Office will still require that the second tab in the Macro Security settings be set properly.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!