Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default macros to make macros

The vba code I am working with generates a file with multiple worksheets. As
the worksheets are created, names are assigned.
I would like to add some code to ThisWorkBook for the created file so that
when a specific sheet in the new workbook is activated, a toolbar appears.

I am not sure how to write a code that will write code in another file.

Any thoughts?
TIA
Papa J
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default macros to make macros

Chip Pearson has some instructions on how to remove code (or add code) on the
fly.
http://www.cpearson.com/excel/vbe.htm

But I would take a different approach. Are you showing the toolbar based on the
name of the worksheet?

If yes, are they nicely named--always begin with the same string (or always
contain the same indicator)?

Maybe just modifying the code to look for that indicator would be enough:

Option Explicit
Private Sub Workbook_SheetActivate(ByVal Sh As Object)

If LCase(Sh.Name) Like "indicator*" Then
Application.CommandBars("custom1").Visible = True
Else
Application.CommandBars("custom1").Visible = False
End If

End Sub



Papa Jonah wrote:

The vba code I am working with generates a file with multiple worksheets. As
the worksheets are created, names are assigned.
I would like to add some code to ThisWorkBook for the created file so that
when a specific sheet in the new workbook is activated, a toolbar appears.

I am not sure how to write a code that will write code in another file.

Any thoughts?
TIA
Papa J


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default macros to make macros

I like the idea. I'll give it a shot.
Thanks

"Dave Peterson" wrote:

Chip Pearson has some instructions on how to remove code (or add code) on the
fly.
http://www.cpearson.com/excel/vbe.htm

But I would take a different approach. Are you showing the toolbar based on the
name of the worksheet?

If yes, are they nicely named--always begin with the same string (or always
contain the same indicator)?

Maybe just modifying the code to look for that indicator would be enough:

Option Explicit
Private Sub Workbook_SheetActivate(ByVal Sh As Object)

If LCase(Sh.Name) Like "indicator*" Then
Application.CommandBars("custom1").Visible = True
Else
Application.CommandBars("custom1").Visible = False
End If

End Sub



Papa Jonah wrote:

The vba code I am working with generates a file with multiple worksheets. As
the worksheets are created, names are assigned.
I would like to add some code to ThisWorkBook for the created file so that
when a specific sheet in the new workbook is activated, a toolbar appears.

I am not sure how to write a code that will write code in another file.

Any thoughts?
TIA
Papa J


--

Dave Peterson

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
make macros in charts jana Charts and Charting in Excel 1 November 18th 08 08:57 AM
make macros usable! make instructions in plain english !!!! Brainless_in_Boston Excel Worksheet Functions 0 March 2nd 06 03:27 PM
weird saving of a document with macros resulting with macros being transfered to the copy alfonso gonzales Excel Programming 0 December 12th 04 09:19 PM
Combining Macros to make one Macro. jdtivoli Excel Programming 1 July 27th 04 11:51 AM
thanks TOM. How to run macros and make the workbooks invisible christine Excel Programming 3 January 5th 04 12:59 PM


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