Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro Runs if Template name is .....

How can I automatically run a VBA macro based on the name of the template
the workbook was made from?
ie my template name is "bracing.xlt"
and I want all documents based on this to auto run a macro on opening.
(The macro will be used to load certain toolbars which are relevant to only
these workbooks.
I can run it manually but I want to automate it)

Thanks in advance


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Macro Runs if Template name is .....

Put the macro in the Workbook_Open event of the template.

--

Vasant


"Nigel Downing" wrote in message
...
How can I automatically run a VBA macro based on the name of the template
the workbook was made from?
ie my template name is "bracing.xlt"
and I want all documents based on this to auto run a macro on opening.
(The macro will be used to load certain toolbars which are relevant to

only
these workbooks.
I can run it manually but I want to automate it)

Thanks in advance




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro Runs if Template name is .....

Thanks for the help but I need this explained more.
Do I make a vba module in the template file and in that define a

public sub () Workbook_Open
'macro call goes here
' ..........
End Sub

?

Nigel
(still on Excel 97)


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Put the macro in the Workbook_Open event of the template.

--

Vasant


"Nigel Downing" wrote in message
...
How can I automatically run a VBA macro based on the name of the

template
the workbook was made from?
ie my template name is "bracing.xlt"
and I want all documents based on this to auto run a macro on opening.
(The macro will be used to load certain toolbars which are relevant to

only
these workbooks.
I can run it manually but I want to automate it)

Thanks in advance






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Macro Runs if Template name is .....

When you're in the VBE, you can hit ctrl-R to see the project explorer.

Find you your project and select it.
hit the asterisk on the numeric keypad to expand all the levels.

You'll see a ThisWorkbook item under the "microsoft excel objects".

That's where your code could go.

Alternatively, you could put your macro in a General module and name it
Auto_open.

Then each time the template opens (and each time a workbook based on that
template) opens, your code will run.

Nigel Downing wrote:

How can I automatically run a VBA macro based on the name of the template
the workbook was made from?
ie my template name is "bracing.xlt"
and I want all documents based on this to auto run a macro on opening.
(The macro will be used to load certain toolbars which are relevant to only
these workbooks.
I can run it manually but I want to automate it)

Thanks in advance


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro Runs if Template name is .....

Thanks Dave

I've now got it working fine by putting the macro in a General module and
named it Auto_open.

But I'm curious as to your first answer. I can see the listing of
sub-headings such as
AcceptLabelsInFormulas
Date1904
IsAddIn
etc and the editable item immediately to the right of each.
Which item do I put the macro in?
Or is this a feature of later versions of excel (I use office 97)
?

Thanks

Nigel




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro Runs if Template name is .....

It sounds like you are looking at the properties window of the ThisWorkbook
part of your project. You would right click on thisworkbook (back in the
project explorer window) and select view code. This will bring up the
Thisworkbook module. At the top of the module will be two dropdowns.
Select Workbook in the left one and then Open in the right one.

--
Regards,
Tom Ogilvy

Nigel Downing wrote in message
...
Thanks Dave

I've now got it working fine by putting the macro in a General module and
named it Auto_open.

But I'm curious as to your first answer. I can see the listing of
sub-headings such as
AcceptLabelsInFormulas
Date1904
IsAddIn
etc and the editable item immediately to the right of each.
Which item do I put the macro in?
Or is this a feature of later versions of excel (I use office 97)
?

Thanks

Nigel




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
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
Why macro runs on the same sheet? Harshad[_2_] Excel Discussion (Misc queries) 1 September 15th 08 09:39 AM
I need a macro that runs other macros until P5=28 Jeff Excel Discussion (Misc queries) 6 May 7th 08 11:44 PM
One macro runs then it auto runs another macro PG Excel Discussion (Misc queries) 2 September 1st 06 09:30 PM
Which Macro Runs...? Bill Martin Excel Discussion (Misc queries) 7 September 29th 05 12:42 PM


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