Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default cpearson VBE question

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
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
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Capturing and saving image from a url link-CPEARSON samboy Excel Discussion (Misc queries) 1 January 12th 09 06:01 PM
Nested IF: Using CPEARSON Approach JeffRI Excel Worksheet Functions 3 March 26th 08 06:07 PM
Sum Time - strange result (site & cpearson researched) proverbs Excel Worksheet Functions 4 May 14th 07 12:19 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM


All times are GMT +1. The time now is 03:56 PM.

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"