View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Code termination resets public variable

I don't know about the ribbon, but does any of your code use End (not End Sub,
End Function, End if), just plain old End.

This will reset those variables.

rogge wrote:

A variable, boolRenameSheets, is declared in a module at the module (General)
level. Speudo Code is below with the important declarations...

boolRenameSheets is being Watched (Break When Value Changes); the code never
breaks after modPublicMacros.runSimulationQuestion has begun.

Thank you all in advance for helping me with this conundrum.

Here is the process...

A) Set boolRenameSheets = True (occurs when ribbon is first accessed (ie
open workbook) and when checkbox is ticked) this module the only place that
contains 'boolRenameSheets ='. elsewhere "if boolRenameSheets then" is
used... this make it very evident the my code does not change
boolRenameSheets.
B) ReDimensions (not-preserve by design) populates some arrays
C) Runs code in a DLL that uses the arrays
D) deletes sheets meeting a specified criteria
E) creates new sheets and populates cells on these sheets
F) MsgBox indicating the process completed (and also boolRenameSheets)

THIS IS WHAT HAPPENS:
0 - ribbonCallBacks.cbSetRenameSheets) Set boolRenameSheets = True using the
ribbon

1 - modPublicMacros.runSimulationQuestion) Run the special code...

2 - modSpecialCode.runSimulation) Display boolRenameSheets immediately
before code execution stops
boolRenameSheets = True

3 - Immediate Window) Use the immediate window to verify boolRenameSheets
immediately after step 2 finishes
? boolRenameSheets
False

_________________________________________________
'modPublicMacros

Option Compare Binary
Option Explicit
Option Base 0

Public boolPrintDerivatives As Boolean
Public boolRenameSheets As Boolean

Public Sub runSimulationQuestion
'Pseudo Code....
if msgBox() = vbYes Then modSpecialCode.runSimulation
End Sub

_________________________________________________
'ribbonCallBacks

Option Private Module
Option Compare Binary
Option Explicit
Option Base 0

'Callback for chkRenameSheets getPressed
Public Sub gpRenameSheets(ByVal control As IRibbonControl, ByRef returnedVal)
'Set default value to True
returnedVal = True
boolRenameSheets = True
End Sub

'Callback for chkRenameSheets onAction
Public Sub cbSetRenameSheets(ByVal control As IRibbonControl, ByVal pressed
As Boolean)
'Set value to checkbox value
boolRenameSheets = pressed
End Sub

_________________________________________________
'modSpecialCode

Option Private Module
Option Compare Binary
Option Explicit
Option Base 0

Public Sub runSimulation()
runSimulationPartA
End Sub

Private Sub runSimulation
deleteSheets
GetInput
runSimulationDLL
populateOutput
MsgBox boolRenameSheets & " complete" 'Shows true when
runSimulationPartA begins execution with boolRenameSheets = true
End Sub

Private Sub deleteSheets
'delete old sheets
End Sub

Private Sub GetInput
'populate arrays
End Sub

Private Sub runSimulationDLL
'Execute the dll
End Sub

Private Sub populateOutput
'create new sheets
End Sub


--

Dave Peterson