Previous  Home  Next

What's the path to the PPA (add-in) file?

If your add-in requires additional files, you'll probably keep them in the same folder as the add-in itself.

Ah, but where's that? A user might install an add-in from anywhere on the local hard drive or even from a network drive, so you can't be certain where the add-in and its associated files are. At least not without this:

Public Function PPAPath(AddinName as String) As String
' Returns the path to the named add-in if found, null if not
' Dependencies:  SlashTerminate (listed below, explained later)

	Dim x As Integer
	PPAPath = ""

	For x = 1 To Application.AddIns.count
		If UCase(Application.AddIns(x).Name) = UCase(AddinName) Then
			' we found it, so
			PPAPath = Application.AddIns(x).path & GetPathSeparator
			' no need to check any other addins
			Exit Function
		End If
	Next x

	' So we can run it from a PPT in the IDE instead of a PPA:
	If PPAPath = "" Then
		PPAPath = SlashTerminate(ActivePresentation.path)
	End If

End Function

Function SlashTerminate(sPath as String) as String
' Returns a string terminated with a path separator character
' Works on PC or Mac

	Dim PathSep As String
	#If Mac Then
		PathSep = ":"
	#Else
		PathSep = "\"
	#End If

	' Is the rightmost character a backslash?
	If Right$(sPath,1) <> PathSep Then
		' No; add a backslash
		SlashTerminate = sPath & PathSep
	Else
		SlashTerminate = sPath
	End If

End Function
Previous  Home  Next