MsgBox

EdPianoMan

New Member
Joined
May 27, 2011
Messages
1
I want to perform the equivalent of MsgBox in my VB.NET application which uses Excel programmatically.

I'm writing an application in VB.NET. I create an instance of the Excel application object and then create a worksheet. The code populates
the worksheet with data and then attempts to write the worksheet to an Excel file. If the user has an existing Excel file open with the same file name as the one one the code is attempting to create\write Excel throws an exception.

To prevent the exception from occurring I wrote a module to detect if there is an Excel file open with the same file name as the one I want to write. If there is a file open then I want to ask the user to close the Excel file and click OK to continue operation so my VB.NET app can write the worksheet to the file.

I'd like to ask the user to close the open file using an equivalent of MsgBox dialog. However, the only dialog box I can find in the Excel application object is InputBox (I know there is the Dialogs collection but none of those dialogs appear to provide the MsgBox functionality. Also, I can't find much documentation on these dialog boxes).

At the moment I've coded my app to use InputBox. It's not the best solution. I would like to use something like MsgBox. Anyone have suggestions?

Ed
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,224,590
Messages
6,179,753
Members
452,940
Latest member
rootytrip

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