#1   Report Post  
Posted to microsoft.public.excel.misc
KJ KJ is offline
external usenet poster
 
Posts: 43
Default Run macro at open

I have a particular easy macro I created that runs when I open a quote
workbook.
I have a separate workbook where I log all my quotes with quote numbers. On
my "Blank Quote" workbook I have a cell (out of the print area) that returns
the highest quote number listed from my "Log" file. I have another cell next
to it that takes that highest quote number and adds "1". Thus giving me my
next available quote number.

The macro I created copies that next available quote number, copies, and
pastes it as a value in the print area in my Quote number field. The idea was
that after I save my "Blank Quote" workbook as a quote number (ei Quote 150)
I could re-open my quote number 150 at a later date and always have the quote
number field return "150". Before I was just manually typing it.

I wasn't thinking ahead. Everytime I re-open quote "150", it runs the macro
again. If I've done other quotes since then, it changes the quote number to
whatever the highest number is again, plus 1.

Question: Can I save as, and not carry over this macro? Or is there another
way to accomplish my end goal?

Any help would be greatly appreciated!! FYI, I'm running 2007, but save most
everything in the 97-2000 compatible format so they can be used by others.
Also, creating this macro to run at the open workbook stage is the most
advanced vba thing I've ever done.

Thanks everybody!! Ken.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Run macro at open

You are in control when you open the file. If you want the macro to run,
open it normally. If you don't want the macro to run, open it in Office Safe
Mode.
--
Gary''s Student - gsnu200771


"KJ" wrote:

I have a particular easy macro I created that runs when I open a quote
workbook.
I have a separate workbook where I log all my quotes with quote numbers. On
my "Blank Quote" workbook I have a cell (out of the print area) that returns
the highest quote number listed from my "Log" file. I have another cell next
to it that takes that highest quote number and adds "1". Thus giving me my
next available quote number.

The macro I created copies that next available quote number, copies, and
pastes it as a value in the print area in my Quote number field. The idea was
that after I save my "Blank Quote" workbook as a quote number (ei Quote 150)
I could re-open my quote number 150 at a later date and always have the quote
number field return "150". Before I was just manually typing it.

I wasn't thinking ahead. Everytime I re-open quote "150", it runs the macro
again. If I've done other quotes since then, it changes the quote number to
whatever the highest number is again, plus 1.

Question: Can I save as, and not carry over this macro? Or is there another
way to accomplish my end goal?

Any help would be greatly appreciated!! FYI, I'm running 2007, but save most
everything in the 97-2000 compatible format so they can be used by others.
Also, creating this macro to run at the open workbook stage is the most
advanced vba thing I've ever done.

Thanks everybody!! Ken.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Run macro at open

You can use code from Chip Pearson's site to remove your code--but it's subject
to the user's security settings.

http://cpearson.com/excel/vbe.aspx

Maybe easier would be to check the name of the file before you do the real work:

If you're using the Auto_Open procedu

if lcase(thisworkbook.name) = lcase("blank quote") then
'do the work
end if

If you're using the Workbook_Open event:

if lcase(me.name) = lcase("blank quote") then
'do the work
end if

Other options would be to check the .FullName (which includes the path) or the
..Path itself.

And maybe you could even check a cell that's empty in the master, but completed
in the "real" workbook.

if isempty(thisworkbook.worksheets("sheet999").range( "a1")) then
'do the work
end if


KJ wrote:

I have a particular easy macro I created that runs when I open a quote
workbook.
I have a separate workbook where I log all my quotes with quote numbers. On
my "Blank Quote" workbook I have a cell (out of the print area) that returns
the highest quote number listed from my "Log" file. I have another cell next
to it that takes that highest quote number and adds "1". Thus giving me my
next available quote number.

The macro I created copies that next available quote number, copies, and
pastes it as a value in the print area in my Quote number field. The idea was
that after I save my "Blank Quote" workbook as a quote number (ei Quote 150)
I could re-open my quote number 150 at a later date and always have the quote
number field return "150". Before I was just manually typing it.

I wasn't thinking ahead. Everytime I re-open quote "150", it runs the macro
again. If I've done other quotes since then, it changes the quote number to
whatever the highest number is again, plus 1.

Question: Can I save as, and not carry over this macro? Or is there another
way to accomplish my end goal?

Any help would be greatly appreciated!! FYI, I'm running 2007, but save most
everything in the 97-2000 compatible format so they can be used by others.
Also, creating this macro to run at the open workbook stage is the most
advanced vba thing I've ever done.

Thanks everybody!! Ken.


--

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
Auto Open Macro Launchnet Excel Worksheet Functions 7 July 20th 07 07:41 PM
Run on open macro JaB Excel Worksheet Functions 1 January 23rd 07 12:54 PM
On Open Macro Tom Excel Discussion (Misc queries) 2 April 1st 06 07:20 PM
Macro - Open Word with Excel macro Bill Excel Discussion (Misc queries) 3 May 23rd 05 11:21 PM
How do I get my personal macro worksheet to open whenever I open . Claudia_R Excel Discussion (Misc queries) 3 December 9th 04 11:59 PM


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