Answering a dialog box within a macro


Posted by Melanie on August 29, 2001 6:40 AM

Hello~

I have a macro in a workbook which opens another workbook. The macro provides the password to the second workbook thanks to Jerik!

Here is today's question:

How can I answer a dialog box that comes up when I run my macro? I can't just supress the dialog box because it defaults to the incorrect answer!

The dialog box in question is one which asks "This file should be opened as "read only." Do you want to open it as "read only?" The default (thus box supressed) answer is yes. I need to answer no.

Thanks!
Melanie

Posted by Dax on August 29, 2001 7:40 AM

Try this:-

Workbooks.Open FileName:="C:\YourFile.xls", IgnoreReadOnlyRecommended:=True

Regards,
Dax.



Posted by JAF on August 29, 2001 7:43 AM

Sub Open_File()
Workbooks.Open Filename:="C:\My Documents\test.xls", WriteResPassword:="open_sesame"
End Sub

The above will open the specified file with the WriteResPassword - in other words, the macro "types" the password for you.

Hope this helps.

JAF