Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default preventing addIn opening in second instance of Excel?

I have an AddIn into which are written a few small details before
close (I know this isn't great practice but it saves me having to
setup a log file external to the AddIn and the attendant risk that
this will be deleted)

When a second instance of excel is opened it opens the AddIn as read-
only. On shut down this prevents the few small details being written
back to it and the user is prompted to save a copy of the AddIn
elsewhere. Undesirable

Two solutions come to mind (beyond setting up a remote log file) but I
don't know how to effect either
1. prevent the second instance of excel from opening the AddIn
(preferable)
2. prevent the addin from working in the second instance, hence not
generating the few small details and not being able to save them

How can I get the second instance of excel NOT to load the addin?
Thanks in advance ... and thanks to all for all the databased
contributions here ... if this group wasn't here I'd still be spending
all afternoon charting data instead of doing it at the touch of a
button!
Matthew

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default preventing addIn opening in second instance of Excel?

In an open event -

If Thisworkbook.Readonly then
Thisworkbook.close
End if

Or, abort any routines you don't want to process
If ThisWorbook.Readonly then Exit Sub
perhaps assign .ReadOnly to a global boolean

In theory it might be possible to change the registry setting for installed
addins in the addin's open event if the addin is not readonly, then reset in
the close. Would prevent the addin opening in further instances but a bit
risky.

Why not store your store your 'few small details' in the registry, look into
SaveSetting and the See also's in help.

Regards,
Peter T



"Matthew Dodds" wrote in message
oups.com...
I have an AddIn into which are written a few small details before
close (I know this isn't great practice but it saves me having to
setup a log file external to the AddIn and the attendant risk that
this will be deleted)

When a second instance of excel is opened it opens the AddIn as read-
only. On shut down this prevents the few small details being written
back to it and the user is prompted to save a copy of the AddIn
elsewhere. Undesirable

Two solutions come to mind (beyond setting up a remote log file) but I
don't know how to effect either
1. prevent the second instance of excel from opening the AddIn
(preferable)
2. prevent the addin from working in the second instance, hence not
generating the few small details and not being able to save them

How can I get the second instance of excel NOT to load the addin?
Thanks in advance ... and thanks to all for all the databased
contributions here ... if this group wasn't here I'd still be spending
all afternoon charting data instead of doing it at the touch of a
button!
Matthew



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default preventing addIn opening in second instance of Excel?

Thanks Peter, that works.

You suggest aborting routines I don't want to process. If these
routines are spawned by a commercial AddIn to which I have no access,
how could I recognise these processes in code (I know only the AddIn's
VBAProjectName and fileName)

As for writing the 'few small details' into registry I've always
thought writing into registry was somehow risky (??) Shoudl I thinhk
otherwise about it? Horrow stories about risks to machine integrity
down to hamfisted users rather than cautious amateur VBA hacks?)

Thanks

Matthew


On 5 Apr, 23:01, "Peter T" <peter_t@discussions wrote:
In an open event -

If Thisworkbook.Readonly then
Thisworkbook.close
End if

Or, abort any routines you don't want to process
If ThisWorbook.Readonly then Exit Sub
perhaps assign .ReadOnly to a global boolean

In theory it might be possible to change the registry setting for installed
addins in the addin's open event if the addin is not readonly, then reset in
the close. Would prevent the addin opening in further instances but a bit
risky.

Why not store your store your 'few small details' in the registry, look into
SaveSetting and the See also's in help.

Regards,
Peter T

"Matthew Dodds" wrote in message

oups.com...



I have an AddIn into which are written a few small details before
close (I know this isn't great practice but it saves me having to
setup a log file external to the AddIn and the attendant risk that
this will be deleted)


When a second instance of excel is opened it opens the AddIn as read-
only. On shut down this prevents the few small details being written
back to it and the user is prompted to save a copy of the AddIn
elsewhere. Undesirable


Two solutions come to mind (beyond setting up a remote log file) but I
don't know how to effect either
1. prevent the second instance of excel from opening the AddIn
(preferable)
2. prevent the addin from working in the second instance, hence not
generating the few small details and not being able to save them


How can I get the second instance of excel NOT to load the addin?
Thanks in advance ... and thanks to all for all the databased
contributions here ... if this group wasn't here I'd still be spending
all afternoon charting data instead of doing it at the touch of a
button!
Matthew- Hide quoted text -


- Show quoted text -



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default preventing addIn opening in second instance of Excel?

Could the problem you described with your own addin also occur with any
third party, commercial or otherwise? I wouldn't have thought so, but if
really necessary you could write your own code to unload these if they are
ReadOnly.

If you use VBA's SaveSetting, and related functions, there shouldn't be any
risk at all. The absolute worst that could happen is access (permissions) is
blocked by the administrator though unlikely in that particular area of the
registry (not entirely sure about Vista though also no damage).

A small thing to be aware of writing is something like "my addin is
currently loaded in Excel". If your app closes unexpectedly before clearing
the setting it might be there for all time as a false positive.

Regards,
Peter T


"Matthew Dodds" wrote in message
oups.com...
Thanks Peter, that works.

You suggest aborting routines I don't want to process. If these
routines are spawned by a commercial AddIn to which I have no access,
how could I recognise these processes in code (I know only the AddIn's
VBAProjectName and fileName)

As for writing the 'few small details' into registry I've always
thought writing into registry was somehow risky (??) Shoudl I thinhk
otherwise about it? Horrow stories about risks to machine integrity
down to hamfisted users rather than cautious amateur VBA hacks?)

Thanks

Matthew


On 5 Apr, 23:01, "Peter T" <peter_t@discussions wrote:
In an open event -

If Thisworkbook.Readonly then
Thisworkbook.close
End if

Or, abort any routines you don't want to process
If ThisWorbook.Readonly then Exit Sub
perhaps assign .ReadOnly to a global boolean

In theory it might be possible to change the registry setting for

installed
addins in the addin's open event if the addin is not readonly, then

reset in
the close. Would prevent the addin opening in further instances but a

bit
risky.

Why not store your store your 'few small details' in the registry, look

into
SaveSetting and the See also's in help.

Regards,
Peter T

"Matthew Dodds" wrote in message

oups.com...



I have an AddIn into which are written a few small details before
close (I know this isn't great practice but it saves me having to
setup a log file external to the AddIn and the attendant risk that
this will be deleted)


When a second instance of excel is opened it opens the AddIn as read-
only. On shut down this prevents the few small details being written
back to it and the user is prompted to save a copy of the AddIn
elsewhere. Undesirable


Two solutions come to mind (beyond setting up a remote log file) but I
don't know how to effect either
1. prevent the second instance of excel from opening the AddIn
(preferable)
2. prevent the addin from working in the second instance, hence not
generating the few small details and not being able to save them


How can I get the second instance of excel NOT to load the addin?
Thanks in advance ... and thanks to all for all the databased
contributions here ... if this group wasn't here I'd still be spending
all afternoon charting data instead of doing it at the touch of a
button!
Matthew- Hide quoted text -


- Show quoted text -





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
excel docs opening in their own instance - not all in one jcsfny Excel Discussion (Misc queries) 3 September 23rd 08 07:30 PM
opening a new instance of Excel gb4 Setting up and Configuration of Excel 0 April 10th 08 04:48 PM
Opening another instance of Excel [email protected][_2_] Excel Programming 1 December 15th 06 08:45 PM
keep Excel from opening 2nd instance widman Excel Discussion (Misc queries) 0 April 30th 06 01:35 PM
Keep Excel from opening new instance widman Excel Discussion (Misc queries) 7 October 1st 05 01:53 AM


All times are GMT +1. The time now is 05:31 PM.

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"