简体   繁体   English

Excel宏加载项-加载项的位置

[英]Excel Macro Addin - location for addin

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. 每当用户点击保存时,它都应该导致正确标记的excel文件也保存为PDF。 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. 我有一个类似的宏,对于Word来说也没有问题,但是对于我一生来说,我似乎无法弄清楚该宏的去向。

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? 我正在Excel 2007的Xp Sp3上运行。我尝试将其保存在.xlam中的模块中,并保存到C:\\Program Files\\Microsoft Office\\Office12\\XLSTARTC:\\Documents and Settings\\username\\Local Settings\\Application Data\\Microsoft\\Office\\12.0C:\\Documents and Settings\\username\\Templates等,但是没有喜悦?

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

If this is to be an Excel Add-in, then if you call 如果这是一个Excel加载项,则如果您调用

Application.UserLibraryPath()

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\\ 这将为您提供将加载项保存到的目录,类似于:C:\\ Documents and Settings \\ Username \\ Application Data \\ Microsoft \\ AddIns \\

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; 通常,您希望将Excel加载项存储在以下两个位置之一中: either for all users of the pc or for an individual user. 适用于PC的所有用户或单个用户。 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 有关存储加载项的位置,请参见stackoverflow:存储excel加载项的位置

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. 为了存储用户的PDF文档,应使用标准的打开文件对话框(已将用户的文档目录作为根目录预填),为用户提供覆盖保存位置的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM