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: 2
Default Writing Workbook_BeforeSave into workbooks from an XLA

I have search around and found similar problems but not quite the same.


I am trying to put in Workbook_BeforeSave routines into the
"ThisWorkbook" module from a seperate XLA. The code works fine if i
write anything other than "Workbook_BeforeSave" but when I have it in,
it will write the code but then freezes up and then shuts down Excel. I
suspect Excel doesn't like it as Workbook_BeforeSave is a Excel defined
subroutine. Any help will be much appreciated. My (stripped down) code
is as follows:

Sub AddSaveAsFunction(ByVal wkbWorkbook As Workbook,
strBillingSheetName As String)
Dim strSheetCodeName As String
Dim VBThisWkbCodeMod As CodeModule
Dim LineNum As Long
Dim strWkbBeforeSave As String

strSheetCodeName = "ThisWorkbook"

strWkbBeforeSave = "Private Sub Workbook_BeforeSave(ByVal SaveAsUI
As Boolean, Cancel As Boolean)" & Chr(13) & _
vbTab & "Blah Blah" & Chr(13) & _
"End Sub"

Set VBThisWkbCodeMod =
wkbWorkbook.VBProject.VBComponents(strSheetCodeNam e).CodeModule
With VBThisWkbCodeMod
LineNum = .CountOfLines + 1
.InsertLines LineNum, strWkbBeforeSave
End With
End Sub

 
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
HELP!!!! Calling a sub from Workbook_BeforeSave RocketMan[_2_] Excel Discussion (Misc queries) 4 May 31st 07 11:47 PM
Workbook_BeforeSave() bmm Excel Programming 3 August 16th 04 03:37 PM
Workbook_Beforesave getting breached Hari[_3_] Excel Programming 2 June 11th 04 10:57 PM
Workbook_BeforeSave Bill Oertell Excel Programming 5 December 21st 03 07:33 PM
Workbook_BeforeSave() in xla Bent Kjeldsen Excel Programming 6 September 24th 03 01:49 PM


All times are GMT +1. The time now is 08:51 AM.

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"