[英]Excel Macro Addin - location for addin
只是想知道在哪里放置此宏。 每當用戶點擊保存時,它都應該導致正確標記的excel文件也保存為PDF。 我有一個類似的宏,對於Word來說也沒有問題,但是對於我一生來說,我似乎無法弄清楚該宏的去向。
我正在Excel 2007的Xp Sp3上運行。我嘗試將其保存在.xlam中的模塊中,並保存到C:\\Program Files\\Microsoft Office\\Office12\\XLSTART
, C:\\Documents and Settings\\username\\Local Settings\\Application Data\\Microsoft\\Office\\12.0
, C:\\Documents and Settings\\username\\Templates
等,但是沒有喜悅?
我是否缺少明顯的東西(不足為奇)?
Sub FileSave()
'
' FileSave Macro
'
'
Dim StrFile As String
Dim StrPath As String
Dim StrName As String
Dim StrPDFName As String
StrPath = ActiveSheet.Path 'Get document path
StrFile = ActiveSheet.Name 'Get document name
If StrName <> "" Then
MsgBox "We have a string name"
StrName = Left(StrFile, (InStr(StrFile, ".") - 1))
StrPDFName = StrPath + "\" + StrName + ".pdf"
If InStr(StrFile, "_fmpro_temp") Then
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= StrPDFName, _
Quality:= xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
MsgBox StrName + " has been saved. " & vbNewLine & _
"If you're finished, please close the file," & vbNewLine & _
"and return to FileMaker to accept or discard this version.", _
vbInformation, "FileMaker Pro Versioning"
End If
End If
End Sub
如果這是一個Excel加載項,則如果您調用
Application.UserLibraryPath()
這將為您提供將加載項保存到的目錄,類似於:C:\\ Documents and Settings \\ Username \\ Application Data \\ Microsoft \\ AddIns \\
外接程序的位置應與外接程序嘗試保存用戶文檔的位置不同。 (即,一般來說,您不會混合程序和文檔)。 通常,您希望將Excel加載項存儲在以下兩個位置之一中: 適用於PC的所有用戶或單個用戶。 區別在於,單個用戶的插件通常是自定義或自定義的。 有關存儲加載項的位置,請參見stackoverflow:存儲excel加載項的位置
為了存儲用戶的PDF文檔,應使用標准的打開文件對話框(已將用戶的文檔目錄作為根目錄預填),為用戶提供覆蓋保存位置的選項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.