Hi All,
Firstly, I have posted this here. I am posting here only because I have not received the answer to my question.
My question is succintly put as follows:
"When opening another workbook using VBA and running a macro from it, how do you go about automating the answer to the MsgBox vbYesNoCancel prompts"
More specifically I have the following macro which I run from master.xls. It opens up a targetworkbook and runs 2 macros from it, "PopulateSheetlist".
[vba]Option Explicit
Sub test()
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Dim targetworkbook As Workbook
Dim usersave As VbMsgBoxResult
Set targetworkbook = Workbooks.Open("C:\Documents and Settings\testingworkbook.xls", UpdateLinks:=0)
Calculate
Application.Run targetworkbook.Name & "!PopulateSheetlist"
response = vbYes
targetworkbook.Activate
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
End Sub
[/vba]
The above code runs fine overall. After " Application.Run targetworkbook.Name & "!PopulateSheetlist"" runs "PopulateSheetlist", There is a vbYesNoCancel prompt that comes up. This vbMsgboxresult is called "response" in "PopulateSheetlist".
I have tried to tell the macro that I want response = vbYes for my purposes, but the alert still pops up and I have to click vbYes manually i.e. response defintion is not automated.
How do I modify the above to tell the macro that it should accept vbYes only.
I know it seems simple, but again, I am stumped.
Any help greatly appreciated.