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: 1
Default EXCEL.exe has created errors and will be closed by Windows.

I have a macro that runs from an add-in. In this macro is code t
insertlines in to a Sub Procedure on a different workbook. This is th
code I have so far, but I get the error below when the code reaches th
line:
LineNum = CountOfLines + 1

EXCEL.exe has created errors and will be closed by Windows.

Any help would be greatly appriciated.

Dim cmbBtn As OLEObject
Dim strCmdName As String
Dim ModEvent As CodeModule 'Module to Modified
Dim LineNum As Long 'Line number in module
Dim SubName As String 'Button Code name
Dim strProc As String 'Procedure string
Dim EndS As String 'End sub string
Dim sTab As String 'Tab
Dim LF As String 'Line feed or carriage return

Ap = Chr(34)
sTab = Chr(9)
LF = Chr(13)
EndS = "End Sub"

Set cmbBtn = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combo Box.1"
Link:=False, DisplayAsIcon:=False, Left:=395.25, Top:=11.8, Width:=96
Height:=27)

SubName = "Private Sub " & cmbBtn.Name & "_Change()" & LF

strProc = "if" & ActiveSheet.Range("e2").Value = "William Day" & "Then
& ActiveSheet.Range("f2").Value = "DAYWI" & "end if"

Set ModEvent
ActiveWorkbook.VBProject.VBComponents(ActiveSheet. CodeName).CodeModule

With ModEvent
LineNum = CountOfLines + 1
.InsertLines LineNum, SubName & strProc & EndS
End Wit

--
Message posted from http://www.ExcelForum.com

 
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.exe has generated errors and will be shutdown by windows jcook Excel Discussion (Misc queries) 0 April 22nd 08 02:20 PM
can not print excel document on mac that was created in windows Dana Excel Discussion (Misc queries) 0 November 30th 06 11:50 PM
Display Charts Created In Excel In A Windows Form Arvindtn Charts and Charting in Excel 0 September 15th 06 03:19 PM
lines in worksheet opened in Windows but created in Excel for Mac Jaws125 Excel Discussion (Misc queries) 3 June 23rd 06 01:15 AM
Errors Opening Excel 2000 files in Windows 98 previously saved in Paul Fraser Excel Discussion (Misc queries) 1 May 9th 05 03:30 PM


All times are GMT +1. The time now is 06:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"