ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   how do i create a dialog box to appear on opening an excel wkbook (https://www.excelbanter.com/excel-discussion-misc-queries/50085-how-do-i-create-dialog-box-appear-opening-excel-wkbook.html)

lallyboo

how do i create a dialog box to appear on opening an excel wkbook
 
I want to create a dialog box that appears on opening an excel workbook along
the lines of "this workbook contains terminated contracts, do you wish to
proceed?". I have seen dialog boxes on workbooks before but do not know how
to create them myself.



Michael J. Strickland

"lallyboo" wrote in message
...
I want to create a dialog box that appears on opening an excel workbook
along
the lines of "this workbook contains terminated contracts, do you wish to
proceed?". I have seen dialog boxes on workbooks before but do not know
how
to create them myself.



Open the workbook and go to the VBA editor (Alt-F11). Click on the "Project
Explorer" icon and select "ThisWorkbook".

At the top of the right hand pane, left side, select "Workbook" from the
drop down list.
At the top of the right hand pane, right side, Select "Open" from the drop
down list.

Put this code in the Workbook_Open event (right hand pane) of the workbook:

Private Sub Workbook_Open()

Dim strResponse As String

strResponse = InputBox("This workbook contains terminated contracts, do
you wish to proceed?", "Input", "N")
If UCase(strResponse) < "Y" Then
Application.Quit
End If

End Sub

--
---------------------------------------------------------------
Michael J. Strickland
Quality Services
703-560-7380
---------------------------------------------------------------




All times are GMT +1. The time now is 08:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com