2012-02-17 61 views
0

只是想知道把宏放在哪里。它应该导致正确标记的Excel文件ato保存为PDF格式,以及每当用户点击保存。我有一个类似的宏工作没有Word的问题,但对我的生活,我似乎无法计算出这个宏的去向。Excel宏插件 - 插件的位置

我在XP SP3运行与Excel 2007年我已经尝试将其保存在一个模块中一个.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等,但没有喜悦之内?

我错过了一些明显的东西(没有意外)?

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 
+0

为什么要在第一个'If'之前添加'debug.print strPath,strFile'?这应该给你一个暗示,我猜。 – 2012-02-17 14:06:36

+0

我也试过'C:\ Program Files \ Microsoft Office \ Office12 \ Startup'这应该是一个值得信赖的位置... – Dycey 2012-02-17 14:20:07

+0

@Dycey:你的问题是否分类? – 2012-03-05 05:10:56

回答

0

如果这是一个Excel加载,那么如果你调用

Application.UserLibraryPath() 

这会给你的目录保存加载项,这将是这样的:C:\ Documents \ Settings \ Username \ Application Data \ Microsoft \ AddIns \

0

插件的位置应该与插件尝试保存用户文档的位置不同。 (即一般你不会混合程序和文件)。 您通常希望将Excel插件存储在两个位置之一中;无论是PC的所有用户还是个人用户。区别在于,个人用户的插件通常是自定义或自组织的。 对于存储的加载项的位置,请参阅stackoverflow: where to store excel addin

存储用户的PDF文档,你应该给用户使用已装设用户的文档目录的标准打开文件对话框覆盖保存位置的选择作为根。

+0

错误,点一,很好。呃,第二点 - 实际上没有。插件的原因是,这是让Excel生成可由另一个系统以编程方式读取的pdf的最简单方法 - 只要其他系统知道去哪里看;-)因此,覆盖保存位置是一个不可。 – Dycey 2012-02-20 10:31:35