Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Removing Macro in ThisWorkbook

Thanks again. I'll just have to remove the code manually. I just like not
having to remember to save the file a certain way in a certain location.
--
I am running on Excel 2003, unless otherwise stated.


"NickH" wrote:

Hi Orion,

I don't believe you can write code that commits suicide and then saves
itself which is effectively what you are trying to do.

Another alternative then is to copy the Template's sheets to a new
workbook and then save that...

Private Sub Workbook_Open()
Dim wbk As Workbook
Dim i As Long

ThisWorkbook.Sheets(1).Copy
Set wbk = ActiveWorkbook

' Change n to the last sheet you want to copy
For i = 2 To n
ThisWorkbook.Sheets(i).Copy After:=wbk.Sheets(i - 1)
Next i

' Rest of your code here to save wbk etc.

End Sub

....this is a bit quick and dirty but hopefully gives you something to
build on.

Br,
NickH

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
Personal.xls macro that writes to ThisWorkBook Derek Bliss Excel Programming 3 July 18th 08 05:26 PM
Macro to add code to ThisWorkbook module excelnut1954 Excel Programming 2 June 2nd 08 08:45 PM
'ThisWorkbook' Macro Question Dan R. Excel Programming 9 January 19th 07 06:16 PM
Module1 vs Thisworkbook for Macro Craigm[_16_] Excel Programming 4 June 28th 05 01:17 PM


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