Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Programmatically Creating Worksheet Event

I'm running Excel XP with the latest service packs on WinXP SP2.

I'm using the following code to import a pivot table event to all the
worksheets of an open workbook 'temp.xls' (tip of the hat to Pierson and
others).

-------------------------
Private Sub CallWriteEventProcedure
Dim wb As Workbook, ws As Worksheet, arrTabs As Variant, i As Integer
arrTabs = Split("Sheet1,Sheet2,Sheet3", ",")
For i = 0 To UBound(arrTabs)
Set wb = Workbooks("Temp.xls")
Set ws = wb.Worksheets(arrTabs(i))
WriteEventProcedure wb, ws
Next
End Sub

Private Sub WriteEventProcedure(wb as workbook, ws as worksheet)
Dim strVBAFilesDir As String
strVBAFilesDir = ThisWorkbook.Path & "\" & "VBA Files"
wb.VBProject.VBComponents.Item(ws.CodeName).CodeMo dule.AddFromFile
strVBAFilesDir & "\" & "PivotTableColumnEvent.txt"
End Sub
-------------------------

The problem is that Excel keeps crashing when I run it. I've tried
rewriting it in lots of different ways (I've run a lot of newgroupsearches
on the problem) but without solving the crashing problem. Is 'vbComponents'
inherently flaky (it's not well documented in the help files) or is there a
bullet proof solution to my problem?

Thanks,
Wayne C.


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
help creating new hyperlinks programmatically J Links and Linking in Excel 1 January 14th 08 08:15 AM
Programmatically Add Worksheet Event The Vision Thing Excel Programming 1 September 2nd 04 02:14 AM
Event Procedures: Event on Worksheet to fire Event on another Worksheet Kathryn Excel Programming 2 April 7th 04 07:35 PM
Creating/Destroying Toolbars Programmatically Syed Zeeshan Haider[_5_] Excel Programming 2 January 27th 04 05:32 AM
Creating Sub CommandButton1_Clk programmatically Jag Man Excel Programming 7 December 14th 03 08:49 PM


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