Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default launching macro on workbook loading

Hi,

Is there a way to have a macro automatically run every time an excel
workbook is opened, where the macro in question resides in the personal.xls
or an add-in rather than being part of the document that is being loaded?

Thanks,
Ric


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default launching macro on workbook loading

If you want to instantiate application level events and have the open event
check each workbook opened to see it is the one - then run the code.

see Chip Pearson's site on application level events

http://www.cpearson.com/excel/AppEvent.htm

--
Regards,
Tom Ogilvy

"Ric" wrote in message
...
Hi,

Is there a way to have a macro automatically run every time an excel
workbook is opened, where the macro in question resides in the

personal.xls
or an add-in rather than being part of the document that is being loaded?

Thanks,
Ric




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default launching macro on workbook loading

Tom Ogilvy wrote:
If you want to instantiate application level events and have the open
event check each workbook opened to see it is the one - then run the
code.

see Chip Pearson's site on application level events

http://www.cpearson.com/excel/AppEvent.htm


"Ric" wrote in message
...
Hi,

Is there a way to have a macro automatically run every time an excel
workbook is opened, where the macro in question resides in the
personal.xls or an add-in rather than being part of the document
that is being loaded?

Thanks,
Ric


Thanks. This works.

I have one annoying problem, though. I now have a macro that runs whenever a
workbook is opened that does a search and replace of a text string on each
sheet of the workbook. However, now I'm always asked if I want to save
changes when I close a workbook, even if the string searched for did not
exist in that workbook. Is there any way to do a search and replace but
leave the "changed" status of the workbook as unchanged if the text string
was not found?

Thanks,
Ric


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default launching macro on workbook loading

workbooks("MyWorkbook.xls").Saved = True

will mark the workbook as unchanged.

so if your macro makes not changes, have it set this property to true after
it has done its search and found no match.

--
Regards,
Tom Ogilvy

Ric wrote in message
...
Tom Ogilvy wrote:
If you want to instantiate application level events and have the open
event check each workbook opened to see it is the one - then run the
code.

see Chip Pearson's site on application level events

http://www.cpearson.com/excel/AppEvent.htm


"Ric" wrote in message
...
Hi,

Is there a way to have a macro automatically run every time an excel
workbook is opened, where the macro in question resides in the
personal.xls or an add-in rather than being part of the document
that is being loaded?

Thanks,
Ric


Thanks. This works.

I have one annoying problem, though. I now have a macro that runs whenever

a
workbook is opened that does a search and replace of a text string on each
sheet of the workbook. However, now I'm always asked if I want to save
changes when I close a workbook, even if the string searched for did not
exist in that workbook. Is there any way to do a search and replace but
leave the "changed" status of the workbook as unchanged if the text string
was not found?

Thanks,
Ric




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default launching macro on workbook loading

Helpful as usual. Thanks!

Ric

Tom Ogilvy wrote:
workbooks("MyWorkbook.xls").Saved = True

will mark the workbook as unchanged.

so if your macro makes not changes, have it set this property to true
after it has done its search and found no match.


Ric wrote in message
...
Tom Ogilvy wrote:
If you want to instantiate application level events and have the
open event check each workbook opened to see it is the one - then
run the code.

see Chip Pearson's site on application level events

http://www.cpearson.com/excel/AppEvent.htm


"Ric" wrote in message
...
Hi,

Is there a way to have a macro automatically run every time an
excel workbook is opened, where the macro in question resides in
the personal.xls or an add-in rather than being part of the
document that is being loaded?

Thanks,
Ric


Thanks. This works.

I have one annoying problem, though. I now have a macro that runs
whenever a workbook is opened that does a search and replace of a
text string on each sheet of the workbook. However, now I'm always
asked if I want to save changes when I close a workbook, even if the
string searched for did not exist in that workbook. Is there any way
to do a search and replace but leave the "changed" status of the
workbook as unchanged if the text string was not found?

Thanks,
Ric






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
Macro not finishing due to loading workbook David P. Excel Discussion (Misc queries) 7 October 14th 08 07:55 PM
Excel Launching and not automatically starting a new workbook joe Excel Discussion (Misc queries) 6 April 11th 07 08:26 PM
personal macro workbook just stopped loading GoBobbyGo Excel Discussion (Misc queries) 4 August 22nd 06 04:27 PM
How to stop Excel remembering/loading macro from previously opened Workbook Norman Yuan Excel Discussion (Misc queries) 4 June 17th 06 04:13 PM
launching excel icon results in not opening workbook BobK Excel Discussion (Misc queries) 1 April 5th 05 12:34 AM


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