Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I sort of found the answer to my questions. If I delete the line:
Worksheets("Estimating Constants").Cells(1, 8).value = 2 The program then works. Worksheets("Estimating Constants") is a valid worksheet, but somehow the program crashes with that line in it. Ron Dahl "Ron Dahl" wrote in message ... I believe that I have used all the code that I can find on Chip Pearson's site, but I'm still having problems. The following code should delete the code module in a worksheet called "Estimate" and then add new code module from the text file. Whenever I run it I get the error message that will hopefully show at the bottom of this posting saying that Microsoft Excel has encountered a problem and must close Can anyone tell me how to fix this? Thanks in advance for any help. Ron Dahl Sub UpgradewksEstimateFromVersion1ToVersion2() On Error Resume Next Application.DisplayAlerts = False Application.EnableEvents = False Application.ScreenUpdating = False If GetCodeModuleExists("Estimate") = True Then DeleteCodeModule ("Estimate") 'See below ActiveWorkbook.VBProject.VBComponents(Worksheets(" Estimate").CodeName).CodeM odule.AddFromFile Filename:="\\ghpd.com\network\prog\est\wksEstimate Events.txt" Else ActiveWorkbook.VBProject.VBComponents(Worksheets(" Estimate").CodeName).CodeM odule.AddFromFile Filename:="\\ghpd.com\network\prog\est\wksEstimate Events.txt" End If ActiveWorkbook.Save Worksheets("Estimating Constants").Cells(1, 8).value = 2 Application.DisplayAlerts = True Application.EnableEvents = True Application.ScreenUpdating = True End Sub Sub DeleteCodeModule(ByVal sname As String) Dim VBCodeMod As CodeModule Dim StartLine As Long Dim HowManyLines As Long Set VBCodeMod = ThisWorkbook.VBProject.VBComponents(Worksheets(sna me).CodeName).CodeModule With VBCodeMod StartLine = 1 HowManyLines = .CountOfLines .DeleteLines StartLine, HowManyLines End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2007 Macro/VB Question DDE Question | Excel Worksheet Functions | |||
Capturing and saving image from a url link-CPEARSON | Excel Discussion (Misc queries) | |||
Nested IF: Using CPEARSON Approach | Excel Worksheet Functions | |||
Sum Time - strange result (site & cpearson researched) | Excel Worksheet Functions | |||
Newbie Question - Subtraction Formula Question | Excel Discussion (Misc queries) |