我有一个名为“abcde.ppam”的PowerPoint插件文件。 我还添加了一个“Auto_Open”Sub,以便在PowerPoint Application启动时运行一些代码。 我的问题是如何在“Auto_Open”中获得名称“abcde.ppam”? 有什么像“ThisAddin.name”或“ThisAddin.path”或其他任何解决方法吗?
答案 0 :(得分:0)
您需要做的就是在加载项的代码中声明一个字符串常量,并将其设置为加载项的名称。
然后你可以做Application.Addins(MyName).Path等等
答案 1 :(得分:0)
sub getMe()
dim MyAddin as addin
dim oAddin as addin
for each oAddin in application.addins
on error resume next
if (application.run ....uniqueFunction) = "YepItsMe" then
Set MyAddin = oAddin
exit for
end if
err.clear
next
'....code acting upon MyAddin
end sub
function uniqueFunction() as string
uniqueFunction="YepItsMe"
end function
答案 2 :(得分:0)
好的,这个方法怎么样。您想要将WhoAmIToday重命名为每个加载项唯一的名称。 WhoMe_ {guid}等。
Sub Auto_Open()
Dim x As Long
Dim sTemp As String
Dim sFilename As String
' Get the internal name of the add-in
sTemp = WhoAmIToday
For x = 1 To Application.AddIns.Count
On Error Resume Next
' Attempt to call the same WhoAmI routine on each addin in the addins collection
If Application.Run(Application.AddIns(x).Name & "!WhoAmIToday") = sTemp Then
If Err.Number = 0 Then
' Found it; here's the name
MsgBox Application.AddIns(x).Name
End If
End If
Next
End Sub
Function WhoAmIToday() As String
WhoAmIToday = "Yes. It's ME"
End Function