Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Get default add-in path

What is the best way to get the default .xla add-in path?

Will this always be Application.UserLibraryPath ?

Or should I use a function like this:

Function GetDefaultAddinPath(Optional strIdentifier _
As String = "\addins\") As String

Dim i As Long
Dim lCount As Long
Dim lPos As Long

strIdentifier = UCase(strIdentifier)
lCount = Application.AddIns.Count

For i = 1 To lCount
lPos = InStr(1, UCase(Application.AddIns(i).FullName), _
strIdentifier, _
vbBinaryCompare)
If lPos 0 Then
GetDefaultAddinPath = Left$(Application.AddIns(i).FullName, _
lPos + Len(strIdentifier) - 1)
Exit Function
End If
Next i

End Function


RBS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Get default add-in path

Hi Bart,

That function appears to return the path of the first addin in the
collection that happens to exist in a folder named somepath\addins. That
assumes there is at least one addin that has a path (ie not one of the
bundled addins) and user hasn't put it in a user named folder of same name
"addins". So I would have thought the simple return you mentioned, or to
cater also for XL97 -

Function GetDefaultAddinPath2() As String
Dim sPath As String, sSep As String
#If VBA6 Then
sPath = Application.UserLibraryPath
#Else
sPath = Application.LibraryPath
#End If
sSep = Application.PathSeparator
If Right$(sPath, 1) < sSep Then
sPath = sPath & sSep
End If
GetDefaultAddinPath2 = sPath
End Function

Regards,
Peter T


"RB Smissaert" wrote in message
...
What is the best way to get the default .xla add-in path?

Will this always be Application.UserLibraryPath ?

Or should I use a function like this:

Function GetDefaultAddinPath(Optional strIdentifier _
As String = "\addins\") As String

Dim i As Long
Dim lCount As Long
Dim lPos As Long

strIdentifier = UCase(strIdentifier)
lCount = Application.AddIns.Count

For i = 1 To lCount
lPos = InStr(1, UCase(Application.AddIns(i).FullName), _
strIdentifier, _
vbBinaryCompare)
If lPos 0 Then
GetDefaultAddinPath = Left$(Application.AddIns(i).FullName, _
lPos + Len(strIdentifier) - 1)
Exit Function
End If
Next i

End Function


RBS



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Get default add-in path

Hi Peter,

I just wondered if Application.UserLibraryPath would be foolproof or if I
needed something
along the lines (but as you say would need to be worked out a bit further)
of the function that
loops through all the add-in path's.

I have now gone with the simple Application.UserLibraryPath.
Thanks for the refinement for XL97 although I don't think I have users on
that anymore.

I needed to know this as despite having an installer that to me seems to
cover all some users still
manage to install to the default add-in folder and that causes all sorts of
problems for my app.
So I check for this and delete (kill) some files if they are there.

Bart


"Peter T" <peter_t@discussions wrote in message
...
Hi Bart,

That function appears to return the path of the first addin in the
collection that happens to exist in a folder named somepath\addins. That
assumes there is at least one addin that has a path (ie not one of the
bundled addins) and user hasn't put it in a user named folder of same name
"addins". So I would have thought the simple return you mentioned, or to
cater also for XL97 -

Function GetDefaultAddinPath2() As String
Dim sPath As String, sSep As String
#If VBA6 Then
sPath = Application.UserLibraryPath
#Else
sPath = Application.LibraryPath
#End If
sSep = Application.PathSeparator
If Right$(sPath, 1) < sSep Then
sPath = sPath & sSep
End If
GetDefaultAddinPath2 = sPath
End Function

Regards,
Peter T


"RB Smissaert" wrote in message
...
What is the best way to get the default .xla add-in path?

Will this always be Application.UserLibraryPath ?

Or should I use a function like this:

Function GetDefaultAddinPath(Optional strIdentifier _
As String = "\addins\") As String

Dim i As Long
Dim lCount As Long
Dim lPos As Long

strIdentifier = UCase(strIdentifier)
lCount = Application.AddIns.Count

For i = 1 To lCount
lPos = InStr(1, UCase(Application.AddIns(i).FullName), _
strIdentifier, _
vbBinaryCompare)
If lPos 0 Then
GetDefaultAddinPath = Left$(Application.AddIns(i).FullName, _
lPos + Len(strIdentifier) - 1)
Exit Function
End If
Next i

End Function


RBS




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
how set default path? Ian Elliott Excel Programming 2 August 2nd 06 01:26 AM
how set default path? GS Excel Programming 1 February 3rd 06 11:32 AM
how set default path? JMB Excel Programming 0 February 3rd 06 11:20 AM
Default path Maileen Excel Programming 1 September 29th 04 09:17 PM
Default Path for Add-Ins Hamilton R. Romano Excel Programming 2 July 28th 04 03:39 PM


All times are GMT +1. The time now is 04:03 AM.

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"