VB Script, Save As function and 2 hanging dialogue boxes

keifin

New Member
Joined
Jun 27, 2012
Messages
2
Greetings:

I have a question. Below is my code that I am using to open a xlsm file, run a macro, save the file as another file name. The code is working just fine. The problem I am having is when the Save As is called I am getting (2) dialogue boxes. The first one says

"The following resources cannot be saved in macro-free workbooks: *VB Project. TO save a file with these features, click no, and then choose a macro-enabled file type in the file type list. To continue saving as a macro-free workbook click yes." --- Here I want to choose yes

The second one says
"Privacy warning: This document contains macros, ActiveX controls, XML expansion pack information or web components. These may include personal information that cannot be removed by the document inspector." --- Here I want to choose OK.

My question is I want my script to be automatic and not just hang at the end waiting for an input. Is there a way I can prevent these messages from appearing and just have the excel save the file as and close without getting these boxes or is there away I can add code to accept yes to the first box and no to the second? I do want to save the file as macro free.

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open ("C:\MyStuff\Template.xlsm")
objExcel.Run "ErrorLogTemplate.xlsm!'Macro1'"
objExcel.ActiveWorkbook.SaveAs "C:\MyStuff\Template "&MyDate&".xlsx", 51
objExcel.Quit

Thank you for any help or advice.
Regard,
Keith
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,207,011
Messages
6,076,141
Members
446,187
Latest member
LMill

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