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: 36
Default Excel crashes when adding code using vbproject object?

Hi,
I'm running Office 2003, the code below causes Excel to crash. I tried to
accomplish this with several workarounds but it still crashed Excel. Any
ideas?
It usually crashes at the "End With" statement

filename1 = ThisWorkbook.Path & "\tempmoditerate.bas"
filename2 = ThisWorkbook.Path & "\tempmodrunsfgcalcs.bas"
filename3 = ThisWorkbook.Path & "\tempmodsfcalcs.bas"
filename4 = ThisWorkbook.Path & "\menuxxx.bas"

ThisWorkbook.VBProject.vbcomponents("modIterate"). Export filename1
ThisWorkbook.VBProject.vbcomponents("runsfgcalcs") .Export filename2
ThisWorkbook.VBProject.vbcomponents("sfcalcs").Exp ort filename3
ThisWorkbook.VBProject.vbcomponents("ThisWorkbook" ).Export filename4

Set vbp = ActiveWorkbook.VBProject
On Error Resume Next
With vbp.vbcomponents
.Remove vbp.vbcomponents("moditerate")
.Import filename1
.Remove vbp.vbcomponents("runsfgcalcs")
.Import filename2
.Remove vbp.vbcomponents("sfcalcs")
.Import filename3

Lines = vbp.vbcomponents("thisworkbook").codemodule.counto flines
vbp.vbcomponents("thisworkbook").codemodule.delete lines 1, Lines
vbp.vbcomponents("thisworkbook").codemodule.addfro mfile filename4
vbp.vbcomponents("thisworkbook").codemodule.delete lines 1, 4
End With

Kill filename1
Kill filename2
Kill filename3
Kill filename4
 
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
Unlock/Lock VBProject through code? dominicb[_97_] Excel Programming 0 August 24th 05 10:54 PM
Unlock/Lock VBProject through code? djvice Excel Programming 0 August 24th 05 10:08 PM
Simple code crashes Excel John[_60_] Excel Programming 1 October 27th 04 05:59 PM
method vbproject of object workbook fail Chrispy[_2_] Excel Programming 4 January 9th 04 06:56 AM
Code in ThisWorkbook crashes Excel Pat Beck Excel Programming 6 August 25th 03 09:07 AM


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