Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Closing Dataform automatically

I have a spreadsheet used as a database. Upon open or activation I want to
show the dataform automatically. Upon close or deactivation of the worksheet
I want it to close automatically.

My code on closing or deactivation doesn't work. You have to physically
select the close button on the form or use Alt-L for the keyboard shortcut.
Apparently the open form precludes the macros.

Can I close the form automatically and, if so, how?

My code (in ThisWorkbook)

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
SendKeys "%{L}", True
End Sub

Private Sub Workbook_Open()
On Error Resume Next
ActiveSheet.ShowDataForm
End Sub

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
On Error Resume Next
ActiveSheet.ShowDataForm
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
On Error Resume Next
SendKeys "%{L}", True
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Closing Dataform automatically

It sure looks to me that you can't change sheets/windows until you dismiss that
Data|Form.

How about just hitting the Escape key?



Dkline wrote:

I have a spreadsheet used as a database. Upon open or activation I want to
show the dataform automatically. Upon close or deactivation of the worksheet
I want it to close automatically.

My code on closing or deactivation doesn't work. You have to physically
select the close button on the form or use Alt-L for the keyboard shortcut.
Apparently the open form precludes the macros.

Can I close the form automatically and, if so, how?

My code (in ThisWorkbook)

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
SendKeys "%{L}", True
End Sub

Private Sub Workbook_Open()
On Error Resume Next
ActiveSheet.ShowDataForm
End Sub

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
On Error Resume Next
ActiveSheet.ShowDataForm
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
On Error Resume Next
SendKeys "%{L}", True
End Sub


--

Dave Peterson

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
Set macro to run automatically when closing workbook? Wuddus Excel Discussion (Misc queries) 10 January 20th 15 03:39 PM
automatically close form before closing Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 0 September 19th 08 08:26 PM
To delete a row automatically ocne a closing date expires. bollard Excel Discussion (Misc queries) 9 March 29th 07 03:30 PM
Prevent open excel windows from automatically closing. Prevent Automatic Closing Excel Discussion (Misc queries) 1 April 10th 06 10:27 PM
mail merge-word file automatically closing vishu Excel Discussion (Misc queries) 3 October 24th 05 05:03 PM


All times are GMT +1. The time now is 11:57 PM.

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

About Us

"It's about Microsoft Excel"