PC Review


Reply
Thread Tools Rate Thread

addin running in different Excel instances

 
 
Doug Glancy
Guest
Posts: n/a
 
      29th Oct 2007
I have an addin that saves itself in either the BeforeClose of
AddinUninstall events. If for some reason I open multiple Excel instances,
when I close the one of the later instances the line ThisWorkbook.Save saves
the addin to the active Excel directory, e.g., My Docs. No error is
generated, it just saves a copy to the wrong place.

It's not a big problem if the addins in the multiple instances are not
saved. So instead of ThisWorkbook.Save I wrote code that uses
ThisWorkbook.Saveas and surrounded it with On Error statements and turned of
DisplayAlerts:

If Not ThisWorkbook.Saved Then
'in case it's read-only, which would be true if this were the 2nd (or
more) instance of Excel
On Error Resume Next
Application.DisplayAlerts = False
'I did SaveAs, because if it's read only Save will save to the active
Excel Directory
ThisWorkbook.SaveAs Filename:=ThisWorkbook.FullName
Application.DisplayAlerts = True
On Error GoTo 0
End If
Exit Sub
ErrorHandler:
Application.ScreenUpdating = True
Application.DisplayAlerts = True

This solution falls under the category of "crude but effective, I hope."
Does anybody have a better one?

XL03 Win Vista and XP

Thanks,

Doug

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      29th Oct 2007
I have to ask, why are you saving the addin? It is against one of the major
principles of an addin IMO.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Doug Glancy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have an addin that saves itself in either the BeforeClose of
>AddinUninstall events. If for some reason I open multiple Excel instances,
>when I close the one of the later instances the line ThisWorkbook.Save
>saves the addin to the active Excel directory, e.g., My Docs. No error is
>generated, it just saves a copy to the wrong place.
>
> It's not a big problem if the addins in the multiple instances are not
> saved. So instead of ThisWorkbook.Save I wrote code that uses
> ThisWorkbook.Saveas and surrounded it with On Error statements and turned
> of DisplayAlerts:
>
> If Not ThisWorkbook.Saved Then
> 'in case it's read-only, which would be true if this were the 2nd (or
> more) instance of Excel
> On Error Resume Next
> Application.DisplayAlerts = False
> 'I did SaveAs, because if it's read only Save will save to the active
> Excel Directory
> ThisWorkbook.SaveAs Filename:=ThisWorkbook.FullName
> Application.DisplayAlerts = True
> On Error GoTo 0
> End If
> Exit Sub
> ErrorHandler:
> Application.ScreenUpdating = True
> Application.DisplayAlerts = True
>
> This solution falls under the category of "crude but effective, I hope."
> Does anybody have a better one?
>
> XL03 Win Vista and XP
>
> Thanks,
>
> Doug



 
Reply With Quote
 
Doug Glancy
Guest
Posts: n/a
 
      29th Oct 2007
Bob,

There are a couple of addin settings that are stored on a sheet.

Thanks,

Doug

"Bob Phillips" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have to ask, why are you saving the addin? It is against one of the major
>principles of an addin IMO.
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my
> addy)
>
> "Doug Glancy" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I have an addin that saves itself in either the BeforeClose of
>>AddinUninstall events. If for some reason I open multiple Excel
>>instances, when I close the one of the later instances the line
>>ThisWorkbook.Save saves the addin to the active Excel directory, e.g., My
>>Docs. No error is generated, it just saves a copy to the wrong place.
>>
>> It's not a big problem if the addins in the multiple instances are not
>> saved. So instead of ThisWorkbook.Save I wrote code that uses
>> ThisWorkbook.Saveas and surrounded it with On Error statements and turned
>> of DisplayAlerts:
>>
>> If Not ThisWorkbook.Saved Then
>> 'in case it's read-only, which would be true if this were the 2nd (or
>> more) instance of Excel
>> On Error Resume Next
>> Application.DisplayAlerts = False
>> 'I did SaveAs, because if it's read only Save will save to the active
>> Excel Directory
>> ThisWorkbook.SaveAs Filename:=ThisWorkbook.FullName
>> Application.DisplayAlerts = True
>> On Error GoTo 0
>> End If
>> Exit Sub
>> ErrorHandler:
>> Application.ScreenUpdating = True
>> Application.DisplayAlerts = True
>>
>> This solution falls under the category of "crude but effective, I hope."
>> Does anybody have a better one?
>>
>> XL03 Win Vista and XP
>>
>> Thanks,
>>
>> Doug

>
>


 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      29th Oct 2007
Wouldn't it be better to save these in the registry or in the workbook that
they are applicable to?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Doug Glancy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Bob,
>
> There are a couple of addin settings that are stored on a sheet.
>
> Thanks,
>
> Doug
>
> "Bob Phillips" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I have to ask, why are you saving the addin? It is against one of the
>>major principles of an addin IMO.
>>
>> --
>> HTH
>>
>> Bob
>>
>> (there's no email, no snail mail, but somewhere should be gmail in my
>> addy)
>>
>> "Doug Glancy" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I have an addin that saves itself in either the BeforeClose of
>>>AddinUninstall events. If for some reason I open multiple Excel
>>>instances, when I close the one of the later instances the line
>>>ThisWorkbook.Save saves the addin to the active Excel directory, e.g., My
>>>Docs. No error is generated, it just saves a copy to the wrong place.
>>>
>>> It's not a big problem if the addins in the multiple instances are not
>>> saved. So instead of ThisWorkbook.Save I wrote code that uses
>>> ThisWorkbook.Saveas and surrounded it with On Error statements and
>>> turned of DisplayAlerts:
>>>
>>> If Not ThisWorkbook.Saved Then
>>> 'in case it's read-only, which would be true if this were the 2nd (or
>>> more) instance of Excel
>>> On Error Resume Next
>>> Application.DisplayAlerts = False
>>> 'I did SaveAs, because if it's read only Save will save to the active
>>> Excel Directory
>>> ThisWorkbook.SaveAs Filename:=ThisWorkbook.FullName
>>> Application.DisplayAlerts = True
>>> On Error GoTo 0
>>> End If
>>> Exit Sub
>>> ErrorHandler:
>>> Application.ScreenUpdating = True
>>> Application.DisplayAlerts = True
>>>
>>> This solution falls under the category of "crude but effective, I hope."
>>> Does anybody have a better one?
>>>
>>> XL03 Win Vista and XP
>>>
>>> Thanks,
>>>
>>> Doug

>>
>>

>



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      29th Oct 2007
Or maybe in another file?

Doug Glancy wrote:
>
> Bob,
>
> There are a couple of addin settings that are stored on a sheet.
>
> Thanks,
>
> Doug
>
> "Bob Phillips" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have to ask, why are you saving the addin? It is against one of the major
> >principles of an addin IMO.
> >
> > --
> > HTH
> >
> > Bob
> >
> > (there's no email, no snail mail, but somewhere should be gmail in my
> > addy)
> >
> > "Doug Glancy" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >>I have an addin that saves itself in either the BeforeClose of
> >>AddinUninstall events. If for some reason I open multiple Excel
> >>instances, when I close the one of the later instances the line
> >>ThisWorkbook.Save saves the addin to the active Excel directory, e.g., My
> >>Docs. No error is generated, it just saves a copy to the wrong place.
> >>
> >> It's not a big problem if the addins in the multiple instances are not
> >> saved. So instead of ThisWorkbook.Save I wrote code that uses
> >> ThisWorkbook.Saveas and surrounded it with On Error statements and turned
> >> of DisplayAlerts:
> >>
> >> If Not ThisWorkbook.Saved Then
> >> 'in case it's read-only, which would be true if this were the 2nd (or
> >> more) instance of Excel
> >> On Error Resume Next
> >> Application.DisplayAlerts = False
> >> 'I did SaveAs, because if it's read only Save will save to the active
> >> Excel Directory
> >> ThisWorkbook.SaveAs Filename:=ThisWorkbook.FullName
> >> Application.DisplayAlerts = True
> >> On Error GoTo 0
> >> End If
> >> Exit Sub
> >> ErrorHandler:
> >> Application.ScreenUpdating = True
> >> Application.DisplayAlerts = True
> >>
> >> This solution falls under the category of "crude but effective, I hope."
> >> Does anybody have a better one?
> >>
> >> XL03 Win Vista and XP
> >>
> >> Thanks,
> >>
> >> Doug

> >
> >


--

Dave Peterson
 
Reply With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      29th Oct 2007
Just use a simple .ini file.

RBS

"Doug Glancy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Bob,
>
> There are a couple of addin settings that are stored on a sheet.
>
> Thanks,
>
> Doug
>
> "Bob Phillips" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I have to ask, why are you saving the addin? It is against one of the
>>major principles of an addin IMO.
>>
>> --
>> HTH
>>
>> Bob
>>
>> (there's no email, no snail mail, but somewhere should be gmail in my
>> addy)
>>
>> "Doug Glancy" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I have an addin that saves itself in either the BeforeClose of
>>>AddinUninstall events. If for some reason I open multiple Excel
>>>instances, when I close the one of the later instances the line
>>>ThisWorkbook.Save saves the addin to the active Excel directory, e.g., My
>>>Docs. No error is generated, it just saves a copy to the wrong place.
>>>
>>> It's not a big problem if the addins in the multiple instances are not
>>> saved. So instead of ThisWorkbook.Save I wrote code that uses
>>> ThisWorkbook.Saveas and surrounded it with On Error statements and
>>> turned of DisplayAlerts:
>>>
>>> If Not ThisWorkbook.Saved Then
>>> 'in case it's read-only, which would be true if this were the 2nd (or
>>> more) instance of Excel
>>> On Error Resume Next
>>> Application.DisplayAlerts = False
>>> 'I did SaveAs, because if it's read only Save will save to the active
>>> Excel Directory
>>> ThisWorkbook.SaveAs Filename:=ThisWorkbook.FullName
>>> Application.DisplayAlerts = True
>>> On Error GoTo 0
>>> End If
>>> Exit Sub
>>> ErrorHandler:
>>> Application.ScreenUpdating = True
>>> Application.DisplayAlerts = True
>>>
>>> This solution falls under the category of "crude but effective, I hope."
>>> Does anybody have a better one?
>>>
>>> XL03 Win Vista and XP
>>>
>>> Thanks,
>>>
>>> Doug

>>
>>

>


 
Reply With Quote
 
Doug Glancy
Guest
Posts: n/a
 
      30th Oct 2007
Thanks to all of you for your thoughts.

It's actually a pretty trivial little with one button that can be added to
the Standard or Formatting toolbar. Normally, I'd add it to one of my own
utility menus, but since the user just wanted this one button, I was trying
to duplicate Excel's ability to drag a button to a different place on the
toolbar and then be there the next time they opened Excel (the button is
created with Temporary:=True). So I am storing the index of the button and
a couple other bits of info in a sheet on the addin.

I thought about using the registry, and I had a reason for not doing it, but
now I think that's the way to go. I don't want to add another file for the
sake of a very small addin.

Doug

"RB Smissaert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Just use a simple .ini file.
>
> RBS
>
> "Doug Glancy" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Bob,
>>
>> There are a couple of addin settings that are stored on a sheet.
>>
>> Thanks,
>>
>> Doug
>>
>> "Bob Phillips" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I have to ask, why are you saving the addin? It is against one of the
>>>major principles of an addin IMO.
>>>
>>> --
>>> HTH
>>>
>>> Bob
>>>
>>> (there's no email, no snail mail, but somewhere should be gmail in my
>>> addy)
>>>
>>> "Doug Glancy" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>I have an addin that saves itself in either the BeforeClose of
>>>>AddinUninstall events. If for some reason I open multiple Excel
>>>>instances, when I close the one of the later instances the line
>>>>ThisWorkbook.Save saves the addin to the active Excel directory, e.g.,
>>>>My Docs. No error is generated, it just saves a copy to the wrong
>>>>place.
>>>>
>>>> It's not a big problem if the addins in the multiple instances are not
>>>> saved. So instead of ThisWorkbook.Save I wrote code that uses
>>>> ThisWorkbook.Saveas and surrounded it with On Error statements and
>>>> turned of DisplayAlerts:
>>>>
>>>> If Not ThisWorkbook.Saved Then
>>>> 'in case it's read-only, which would be true if this were the 2nd
>>>> (or more) instance of Excel
>>>> On Error Resume Next
>>>> Application.DisplayAlerts = False
>>>> 'I did SaveAs, because if it's read only Save will save to the
>>>> active Excel Directory
>>>> ThisWorkbook.SaveAs Filename:=ThisWorkbook.FullName
>>>> Application.DisplayAlerts = True
>>>> On Error GoTo 0
>>>> End If
>>>> Exit Sub
>>>> ErrorHandler:
>>>> Application.ScreenUpdating = True
>>>> Application.DisplayAlerts = True
>>>>
>>>> This solution falls under the category of "crude but effective, I
>>>> hope." Does anybody have a better one?
>>>>
>>>> XL03 Win Vista and XP
>>>>
>>>> Thanks,
>>>>
>>>> Doug
>>>
>>>

>>

>


 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      30th Oct 2007
Doug,

If you are saving information about the addin, such as the size of a resized
form, the position of a toolbar, that is legitimate (even in my book <g>),
and the registry is a good place to do so (Jan Karel Pieterse does that with
NameManager), and with GetSetting and SaveSetting it is simple and not
locked down.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Doug Glancy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks to all of you for your thoughts.
>
> It's actually a pretty trivial little with one button that can be added to
> the Standard or Formatting toolbar. Normally, I'd add it to one of my own
> utility menus, but since the user just wanted this one button, I was
> trying to duplicate Excel's ability to drag a button to a different place
> on the toolbar and then be there the next time they opened Excel (the
> button is created with Temporary:=True). So I am storing the index of the
> button and a couple other bits of info in a sheet on the addin.
>
> I thought about using the registry, and I had a reason for not doing it,
> but now I think that's the way to go. I don't want to add another file
> for the sake of a very small addin.
>
> Doug
>
> "RB Smissaert" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Just use a simple .ini file.
>>
>> RBS
>>
>> "Doug Glancy" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Bob,
>>>
>>> There are a couple of addin settings that are stored on a sheet.
>>>
>>> Thanks,
>>>
>>> Doug
>>>
>>> "Bob Phillips" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>I have to ask, why are you saving the addin? It is against one of the
>>>>major principles of an addin IMO.
>>>>
>>>> --
>>>> HTH
>>>>
>>>> Bob
>>>>
>>>> (there's no email, no snail mail, but somewhere should be gmail in my
>>>> addy)
>>>>
>>>> "Doug Glancy" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>>I have an addin that saves itself in either the BeforeClose of
>>>>>AddinUninstall events. If for some reason I open multiple Excel
>>>>>instances, when I close the one of the later instances the line
>>>>>ThisWorkbook.Save saves the addin to the active Excel directory, e.g.,
>>>>>My Docs. No error is generated, it just saves a copy to the wrong
>>>>>place.
>>>>>
>>>>> It's not a big problem if the addins in the multiple instances are not
>>>>> saved. So instead of ThisWorkbook.Save I wrote code that uses
>>>>> ThisWorkbook.Saveas and surrounded it with On Error statements and
>>>>> turned of DisplayAlerts:
>>>>>
>>>>> If Not ThisWorkbook.Saved Then
>>>>> 'in case it's read-only, which would be true if this were the 2nd
>>>>> (or more) instance of Excel
>>>>> On Error Resume Next
>>>>> Application.DisplayAlerts = False
>>>>> 'I did SaveAs, because if it's read only Save will save to the
>>>>> active Excel Directory
>>>>> ThisWorkbook.SaveAs Filename:=ThisWorkbook.FullName
>>>>> Application.DisplayAlerts = True
>>>>> On Error GoTo 0
>>>>> End If
>>>>> Exit Sub
>>>>> ErrorHandler:
>>>>> Application.ScreenUpdating = True
>>>>> Application.DisplayAlerts = True
>>>>>
>>>>> This solution falls under the category of "crude but effective, I
>>>>> hope." Does anybody have a better one?
>>>>>
>>>>> XL03 Win Vista and XP
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Doug
>>>>
>>>>
>>>

>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Excel Addin from VBA in Access....HELP!! Tirelle Microsoft Access VBA Modules 9 3rd Jan 2008 11:08 PM
Running Excel Addin from VBA in Access........Help!!! Tirelle Microsoft Access VBA Modules 0 1st Jan 2008 07:30 AM
All Excel instances inaccessible due to long running macro michaeljc70@hotmail.com Microsoft Excel Discussion 0 8th Dec 2004 12:02 AM
All Excel instances inaccessible due to long running macro michaeljc70@hotmail.com Microsoft Excel Discussion 0 7th Dec 2004 11:15 PM
Load xla addin on demand for particular Excel instances =?Utf-8?B?REtH?= Microsoft Excel Programming 1 9th Jun 2004 04:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:09 AM.