「abcde.ppam」という名前のPowerPointアドインファイルがあります。また、PowerPointアプリケーションの起動時にコードを実行するために、「Auto_Open」サブを追加します。私の質問は、「Auto_Open」で「abcde.ppam」という名前を取得するにはどうすればよいですか?「ThisAddin.name」や「ThisAddin.path」などの回避策はありますか?
3 に答える
1
OK、このアプローチはどうですか。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
于 2017-03-09T17:15:47.807 に答える
0
アドインのコードで文字列定数を宣言し、それをアドインの名前に設定するだけです。
次に、Application.Addins(MyName).Pathなどを実行できます。
于 2013-02-19T00:14:45.377 に答える
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
于 2014-12-16T10:01:38.890 に答える