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: 4
Default Add-in / xla causing random wierd GPF / crash

I've written an Excel Add-in (xla) and had everything working fine. The
'main' purpose of the xla was to have 'template' sheets that the user could
insert into their own workbook via menus that I create on toolbar.

As I said, everything was working fine, then I continued to 'extend' one of
the sheets and I'm not sure what caused the problem, but now when I call the
function that worked before, it always GPFs, and not always in the same
spot. And when I say not always in the same spot, it is always somewhere in
the 4 calls to NewPage()...usually happens right after NewPage "RBLInput",
but 15% of the time happens right BEFORE that call.

Note, the two major changes I made are one of the sheets has fairly complex
charts on them that get copied to new spreadsheet, and also I changed the
code that actually does the copy (part of NewPage() method).

Before, NewPage() used something like this to 'create' the new sheet:

Set oSheet = ActiveWorkbook.Worksheets.Add(Worksheets(n))
ThisWorkbook.Worksheets(sSourcePageName).Cells.Cop y
oSheet.Cells.PasteSpecial xlPasteAll
Application.CutCopyMode = False

Then the charts didn't come over, so I dug a bit to find a .Copy method on
WorkSheet object, so now code is:

Dim myWkSht As Worksheet: Set myWkSht =
ThisWorkbook.Worksheets(sSourcePageName)
Call myWkSht.Copy(ActiveWorkbook.Worksheets(n))
Set oSheet = ActiveWorkbook.Worksheets(n)

So I guess the 'real' question is, has anyone seen a pattern where you get
vba/xla to GPF/Crash 'consistently' for no real apparent reason. The reason
I say no reason, is that after reading the code below, if I do all these
step 'individually' (i.e. call NewPage() four times from Immediate Window)
it seems to work all right. Any tips on going about debuging this (I'm
currently in the process of recreating entire sheet and trying to determine
when it starts to crash) or better resources that I should try (I've
searched google up and down with no luck)

The function that fails is as follows (I can provide more info/code if
necessary):

Sub ConvertToRbl()
On Error GoTo Err_ConvertToRbl

If val(Application.Version) = 10 Then
On Error Resume Next
Dim VBP As Object ' as VBProject
Set VBP = ActiveWorkbook.VBProject
If Err.Number < 0 Then
MsgBox "Your security settings do not allow this procedure to
run." _
& vbCrLf & vbCrLf & "To change your security setting:" _
& vbCrLf & vbCrLf & " 1. Select Tools - Macro - Security." &
vbCrLf _
& " 2. Click the 'Trusted Sources' tab" & vbCrLf _
& " 3. Place a checkmark next to 'Trust access to Visual Basic
Project.'", _
vbCritical
Exit Sub
End If
On Error GoTo 0
End If

NewPage "Info", "RBLInfo"
NewPage "RBLData", "RBLData"
NewPage "RBLInput", "RBLInput"
NewPage "RBLResult", "RBLResult"

Dim oModule As VBComponent
On Error Resume Next
Set oModule = ActiveWorkbook.VBProject.VBComponents("mRBL")
On Error GoTo Err_ConvertToRbl
If Not oModule Is Nothing Then
Call ActiveWorkbook.VBProject.VBComponents.Remove(oModu le)
End If

Set oModule =
ActiveWorkbook.VBProject.VBComponents.Add(vbext_ct _StdModule)
oModule.Name = "mRBL"
If oModule.CodeModule.CountOfDeclarationLines 0 Then
Call oModule.CodeModule.DeleteLines(1,
oModule.CodeModule.CountOfDeclarationLines)
End If
Call
oModule.CodeModule.AddFromString(ThisWorkbook.VBPr oject.VBComponents("mRBLSpreadEngine").CodeModule. Lines(1,
ThisWorkbook.VBProject.VBComponents("mRBLSpreadEng ine").CodeModule.CountOfLines
+
ThisWorkbook.VBProject.VBComponents("mRBLSpreadEng ine").CodeModule.CountOfDeclarationLines))

Call RemoveDefaultSheets

Exit Sub
Err_ConvertToRbl:
MsgBox "Error converting to RBL SpreadEngine." & vbCrLf & vbCrLf &
"Details: " & Err.Description
End Sub


 
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
Conditional formatting causing Excel to crash No Name Excel Discussion (Misc queries) 3 October 10th 08 03:35 PM
Macro Glitch Causing Crash Danimagus Excel Discussion (Misc queries) 1 June 6th 05 06:19 PM
Charts causing program to crash Fysh Charts and Charting in Excel 1 December 16th 04 10:12 PM
Problem with code causing Excel '97 to crash Pozzo[_6_] Excel Programming 0 June 16th 04 08:19 PM


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