Excel 宏插件 - 插件的位置
只是想知道这个宏应该放在哪里。每当用户点击“保存”时,它应该会导致正确标记的 Excel 文件也保存为 PDF。我有一个类似的宏,对于 Word 来说没有任何问题,但对于我来说,我似乎无法弄清楚这个宏的去向。
我在 Xp Sp3 上运行 Excel 2007。我尝试将其保存在 .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
just wondering where to put this macro. It's supposed to cause correctly labelled excel files ato save as PDF as well whenever the user hits save. I have a similar Macro working without issue for Word, but for the life of me I can't seem to work out where this macro goes.
I'm running on Xp Sp3 with Excel 2007. I've tried saving it in a module within a .xlam to 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
etc. but no joy?
Am I missing something obvious (no surprise)?
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果这是一个 Excel 加载项,那么如果您调用
That 将为您提供保存加载项的目录,该目录类似于:C:\Documents and Settings\Username\Application Data\Microsoft\AddIns\
If this is to be an Excel Add-in, then if you call
That will give you the directory to save add-ins to which will be something like: C:\Documents and Settings\Username\Application Data\Microsoft\AddIns\
外接程序的位置应与外接程序尝试保存用户文档的位置不同。 (即一般来说,您不会混合程序和文档)。
您通常希望将 Excel 插件存储在两个位置之一:适用于计算机的所有用户或单个用户。不同之处在于,个人用户的插件通常是自定义的或临时的。
有关存储插件的位置,请参阅 stackoverflow:存储位置excel addin
为了存储用户的 PDF 文档,您应该为用户提供使用标准打开文件对话框覆盖保存位置的选项,该对话框已启动用户的文档目录作为根目录。
The location of the addin should be different from where the addin tries to save the user's documents. (ie in general you don't mix programs and documents).
You typically want to store an Excel addin in one of two places; either for all users of the pc or for an individual user. The difference is, addins for individual users are typically custom or adhoc.
For the locations to store the addins, see stackoverflow: where to store excel addin
For storing the user's PDF document, you should give the user the option of overriding the save location by using the standard open file dialog that has been primed with the user's document directory as the root.