Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 34
Default Dialog box upon opening workbook

Good morning from COB Speicher, Iraq. I have a workbook that I use to
track my Soldiers leave requests to determine how many can be gone at
any given time and still allow us to complete our missions. It has
four worksheets: leave request, calendar, mission capability, and
personnel. How can I create a dialog box that pops up when an Excel
workbook is opened? It should ask if I want to add a leave request
and if answer is yes, open a data form based on the leave request
sheet. If answer is no, it should ask "Which worksheet do you wish to
view?" and open the sheet that is input. Thanks for the help.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default Dialog box upon opening workbook

Private Sub Workbook_Open()
Dim ans As String

If MsgBox("Add a leave request", vbYesNo, "Soldiers Leave") = vbYes Then

LeaveForm.Show
Else

ans = InputBox("Show which sheet?", "Soldiers Leve")
On Error Resume Next
Worksheets(ans).Activate
End If

End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


BTW, what does COB stand for?

--
__________________________________
HTH

Bob

"Anthony" wrote in message
...
Good morning from COB Speicher, Iraq. I have a workbook that I use to
track my Soldiers leave requests to determine how many can be gone at
any given time and still allow us to complete our missions. It has
four worksheets: leave request, calendar, mission capability, and
personnel. How can I create a dialog box that pops up when an Excel
workbook is opened? It should ask if I want to add a leave request
and if answer is yes, open a data form based on the leave request
sheet. If answer is no, it should ask "Which worksheet do you wish to
view?" and open the sheet that is input. Thanks for the help.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 34
Default Dialog box upon opening workbook

On Jan 4, 1:49*am, "Bob Phillips" wrote:
Private Sub Workbook_Open()
Dim ans As String

* * If MsgBox("Add a leave request", vbYesNo, "Soldiers Leave") = vbYes Then

* * * * LeaveForm.Show
* * Else

* * * * ans = InputBox("Show which sheet?", "Soldiers Leve")
* * * * On Error Resume Next
* * * * Worksheets(ans).Activate
* * End If

End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code

BTW, what does COB stand for?

--
__________________________________
HTH

Bob

"Anthony" wrote in message

...



Good morning from COB Speicher, Iraq. *I have a workbook that I use to
track my Soldiers leave requests to determine how many can be gone at
any given time and still allow us to complete our missions. *It has
four worksheets: leave request, calendar, mission capability, and
personnel. *How can I create a dialog box that pops up when an Excel
workbook is opened? *It should ask if I want to add a leave request
and if answer is yes, open a data form based on the leave request
sheet. *If answer is no, it should ask "Which worksheet do you wish to
view?" and open the sheet that is input. *Thanks for the help.- Hide quoted text -


- Show quoted text -


Thanks Bob for the quick response. I will add the code later today
and repost the results. COB stands for contigency operating base.
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 34
Default Dialog box upon opening workbook

On Jan 4, 1:49*am, "Bob Phillips" wrote:
Private Sub Workbook_Open()
Dim ans As String

* * If MsgBox("Add a leave request", vbYesNo, "Soldiers Leave") = vbYes Then

* * * * LeaveForm.Show
* * Else

* * * * ans = InputBox("Show which sheet?", "Soldiers Leve")
* * * * On Error Resume Next
* * * * Worksheets(ans).Activate
* * End If

End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code

BTW, what does COB stand for?

--
__________________________________
HTH

Bob

"Anthony" wrote in message

...



Good morning from COB Speicher, Iraq. *I have a workbook that I use to
track my Soldiers leave requests to determine how many can be gone at
any given time and still allow us to complete our missions. *It has
four worksheets: leave request, calendar, mission capability, and
personnel. *How can I create a dialog box that pops up when an Excel
workbook is opened? *It should ask if I want to add a leave request
and if answer is yes, open a data form based on the leave request
sheet. *If answer is no, it should ask "Which worksheet do you wish to
view?" and open the sheet that is input. *Thanks for the help.- Hide quoted text -


- Show quoted text -


I pasted the code in the VB editor and it gave me the following error
message:
Compile Error: Expected function or Variable
Also, the text "LeaveForm" from the code you provided was highlighted
in blue.
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default Dialog box upon opening workbook

Anthony,

You need to replace LeaveForm in the code with the real name of your form.

--
__________________________________
HTH

Bob

"Anthony" wrote in message
...
On Jan 4, 1:49 am, "Bob Phillips" wrote:
Private Sub Workbook_Open()
Dim ans As String

If MsgBox("Add a leave request", vbYesNo, "Soldiers Leave") = vbYes Then

LeaveForm.Show
Else

ans = InputBox("Show which sheet?", "Soldiers Leve")
On Error Resume Next
Worksheets(ans).Activate
End If

End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code

BTW, what does COB stand for?

--
__________________________________
HTH

Bob

"Anthony" wrote in message

...



Good morning from COB Speicher, Iraq. I have a workbook that I use to
track my Soldiers leave requests to determine how many can be gone at
any given time and still allow us to complete our missions. It has
four worksheets: leave request, calendar, mission capability, and
personnel. How can I create a dialog box that pops up when an Excel
workbook is opened? It should ask if I want to add a leave request
and if answer is yes, open a data form based on the leave request
sheet. If answer is no, it should ask "Which worksheet do you wish to
view?" and open the sheet that is input. Thanks for the help.- Hide
quoted text -


- Show quoted text -


I pasted the code in the VB editor and it gave me the following error
message:
Compile Error: Expected function or Variable
Also, the text "LeaveForm" from the code you provided was highlighted
in blue.




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 34
Default Dialog box upon opening workbook

On Jan 5, 1:22*am, "Bob Phillips" wrote:
Anthony,

You need to replace LeaveForm in the code with the real name of your form..

--
__________________________________
HTH

Bob

"Anthony" wrote in message

...
On Jan 4, 1:49 am, "Bob Phillips" wrote:





Private Sub Workbook_Open()
Dim ans As String


If MsgBox("Add a leave request", vbYesNo, "Soldiers Leave") = vbYes Then


LeaveForm.Show
Else


ans = InputBox("Show which sheet?", "Soldiers Leve")
On Error Resume Next
Worksheets(ans).Activate
End If


End Sub


'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


BTW, what does COB stand for?


--
__________________________________
HTH


Bob


"Anthony" wrote in message


....


Good morning from COB Speicher, Iraq. I have a workbook that I use to
track my Soldiers leave requests to determine how many can be gone at
any given time and still allow us to complete our missions. It has
four worksheets: leave request, calendar, mission capability, and
personnel. How can I create a dialog box that pops up when an Excel
workbook is opened? It should ask if I want to add a leave request
and if answer is yes, open a data form based on the leave request
sheet. If answer is no, it should ask "Which worksheet do you wish to
view?" and open the sheet that is input. Thanks for the help.- Hide
quoted text -


- Show quoted text -


I pasted the code in the VB editor and it gave me the following error
message:
Compile Error: Expected function or Variable
Also, the text "LeaveForm" from the code you provided was highlighted
in blue.- Hide quoted text -

- Show quoted text -


I have done this and I get the same error message. Is there something
that I need to do with regards to the data form. If I run the macro
without the VB code you provided, it opens the data form without any
issues. I created the data form using the record macro function in
Excel 2007 if that makes a difference; it is named "Leave". Sorry for
all the questions. Thanks again.
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Dialog box upon opening workbook

I think Bob assumes you created a UserForm named Leave

Did you do that?

I don't think you can do that by recording a macro.


Gord Dibben MS Excel MVP

On Mon, 5 Jan 2009 10:55:13 -0800 (PST), Anthony
wrote:

I have done this and I get the same error message. Is there something
that I need to do with regards to the data form. If I run the macro
without the VB code you provided, it opens the data form without any
issues. I created the data form using the record macro function in
Excel 2007 if that makes a difference; it is named "Leave". Sorry for
all the questions. Thanks again.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening Excel - getting print dialog box Christina Lynch Excel Discussion (Misc queries) 0 August 31st 08 01:40 AM
Dialog box appears when opening Excel says it can't find a file? Aloha6 Excel Discussion (Misc queries) 2 September 12th 06 01:03 PM
Dialog prompt during opening of file markuss New Users to Excel 1 June 21st 06 11:32 AM
how do i create a dialog box to appear on opening an excel wkbook lallyboo Excel Discussion (Misc queries) 1 October 13th 05 06:52 PM
How can I make Excel display a message (dialog box) upon opening a spreadsheet? Phill Excel Discussion (Misc queries) 8 March 20th 05 06:22 PM


All times are GMT +1. The time now is 11:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"