Force OK the Privacy warning message in macro enabled MS excel using VBA

1.7k views Asked by At

I have written a macro in my excel, which is scheduled to run daily and it is working fine.

But the problem is that whenever the code for saving the excel file is encountered, It prompts a warning message as follows:

Warning message

Here's the VBScript code which is triggering the macro in excel file.

Dim xlApp, xlBook

Set xlApp = CreateObject("Excel.Application")

Set xlBook = xlApp.Workbooks.Open("C:\foo\bar.xlsm", 0, FALSE)
xlApp.Run "Macro1"
xlBook.Save   ' Here is where i need to force OK this warning message
xlBook.Close
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing

Now is there a VBA which I can add while saving, so that i don't have to manually click OK every time, can this be force OK?

Thanks in advance!

0

There are 0 answers