LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Creating ThisWorkbook Event Procedures

I've created a macro that creates individual workbooks from all
worksheets within a multisheet workbook adding some event procedures to
the individual workbooks. I made use of Chip Pearson's page
"Programming To The Visual Basic Editor" to accomplish part of this
activity. The VBE IDE window flashes showing the ThisWorkbook module
that being created for each workbook being created even though I'm
using MainWindow.Visible = False as suggested by post "Creating an
event procedure question". How do I prevent VBE displaying the creation
of the procedures?

I have Excel 2000 (9.0.6926 SP-3).

Here's an outline of my code:
For each worksheet
Application.ScreenUpdating = False
worksheet.copy
Application.VBE.MainWindow.Visible = False
Add event workbook procedures SheetChange, BeforeSave, and
BeforeClose
disable events
SaveAs
Close
enable events
Application.ScreenUpdating = True
Next

Here's the details of adding the events, which _do_ work in the created
workbooks:
With ActiveWorkbook.VBProject.VBComponents("ThisWorkboo k").CodeModule
StartLine = .CreateEventProc("SheetChange", "Workbook") + 1
.InsertLines StartLine, _
" Msgbox ""Please make changes to the Master file."" & vbCr &
""Your changes will not be saved."",vbExclamation+vbOkOnly" & vbCr & _
" Saved = True"

StartLine = .CreateEventProc("BeforeSave", "Workbook") + 1
.InsertLines StartLine, _
" Msgbox ""Will not save changes."",vbExclamation+vbOkOnly" &
vbCr & _
" Cancel = True" & vbCr & _
" Saved = True"

StartLine = .CreateEventProc("BeforeClose", "Workbook") + 1
.InsertLines StartLine, _
" Saved = True"
End With

 
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
many similar event procedures natanz[_2_] Excel Programming 1 November 4th 05 02:26 PM
Event Procedures in an Add-In DJB[_10_] Excel Programming 3 September 17th 05 08:11 AM
learning event procedures R.VENKATARAMAN Excel Programming 4 January 21st 05 01:09 PM
ThisWorkBook BeforeClose Event David Adamson[_4_] Excel Programming 0 July 29th 04 12:32 AM
Creating Event procedures from a macro Robert Stober Excel Programming 3 September 7th 03 06:52 PM


All times are GMT +1. The time now is 06:44 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"