Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default closing another file by code causes failure to run workbookactivate event

On Tuesday, July 10, 2012 9:03:42 AM UTC-4, James Ravenswood wrote:
Post your userform code.


James

I have workbook test1.xlsm with a single userform. The userform has a single button with the following code:

Private Sub CommandButton1_Click()
Workbooks.Open ("test2.xlsm")
Unload Me

End Sub

Workbook text2.xlsm has a worksheet button with the following code:

Private Sub CommandButton1_Click()
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub

WB test1.xlsm has the following in ThisWorkbook code module:

Private Sub Workbook_Activate()
UserForm1.Show
End Sub

The userform is shown whenever test1 is activated; unless test1 is activated by closing test2 through the command button1 code. If test2 is closed with the x button or file close, the userform is shown. I have workaround that is working okay, but, it seems overly complex. I have added the triggering of an OnTime code to the command button code on test2. The OnTime function triggers the redisplay of the original userform after a one second delay. It works, but, I would reall like to know why test1 does not run the activate code when it becomes active through the closing of test2.

Thanks

Ken
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
Chart Activate event not triggered when workbook opened? [email protected] Excel Programming 0 September 2nd 06 02:37 AM
WorkBook Activate event not working [email protected] Excel Programming 14 June 12th 06 09:21 PM
Auto Activate (Window_Open Event) in Personal.xls when another workbook is loaded Nap Excel Programming 7 March 24th 06 09:22 AM
Pasting after Workbook Activate event Michael Malinsky[_2_] Excel Programming 2 June 6th 05 08:01 PM
Insert VBA code with a macro in a .xls file by workbook open event mihai[_3_] Excel Programming 8 July 29th 04 01:49 PM


All times are GMT +1. The time now is 04:10 PM.

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"