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: 134
Default Templates

I am developing an application which will use an Excel
Workbook that has only a menu which, amoung other things
will allow me to open either a specific workbook
previously created or a new workbook. If I create a new
workbook I am using an Excel template for that. In the
template I have code which will need to execute to set
conditions and to prepare the resulting workbook to accept
new data from my user. The problem I am having is, I need
to execute one of two macros within the workbook depending
on if the user chooses to open an existing wlorkbook or a
new workbook. I have no problem if the user chooses an
existing workbook because I know the name of the file.
But...if the user chooses to create a new workbook, when
the template opens, before any events fire it creates a
new workbook. If my template is named Test the new
workbook is named Test1. If I finish the data entry for
that workbook and choose to create another new workbook, I
get Test2, etc. The numbering resets only after I close
the menu workbook and re-open it. My problem comes in my
attempt to execute the macro in the resulting new file. I
do not know (in code) what it will be. I guess I could use
some sort of counter, but that has potential problems.

Any suggestions? How do I execute a macro in a workbook
where I do not know for sure what the name of the new
workbook will be until after my code executes?

The problem this creates is I get an error which is run-
time error 424, object required when I execute the
Application.Run command. The problem is that the new
workbook has been created and the template has been closed
(automatically by Excel). Only after the Excel creates the
new workbook from the template do I have an opportunity to
determine the new workbook name.

Thanks!

Kevin


 
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
saved templates opening as templates 4n6DNA Excel Discussion (Misc queries) 2 August 31st 09 09:30 PM
Templates njlindsey Excel Discussion (Misc queries) 1 October 19th 06 12:18 AM
Excel is opening templates as templates instead of as worksheets Desram Setting up and Configuration of Excel 1 January 19th 06 09:38 PM
Templates double helix Excel Worksheet Functions 1 October 26th 05 12:38 AM
Templates Hera Excel Programming 0 July 20th 03 06:39 PM


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