【问题标题】:Linking Macros to Onedrive将宏链接到 Onedrive
【发布时间】:2023-01-23 20:12:10
【问题描述】:

我正在尝试将文件宏保存到我的团队一个驱动器。这是一份包含多个用户的班次报告,我想在上面放一个“保存副本”按钮,这样当我们点击保存时,它会在我们驱动器上的一个文件夹中创建一个 pdf,该文件夹带有日期、班次和主管的时间戳。以下是我能够从教程网站获得的内容。我有共享驱动器文件夹的 URL,我希望这些文件夹最终位于其中。我需要一些帮助来确定将其插入的位置。现在,当我运行宏时,它会创建一个带有文件名和保存位置的提示。该位置看起来正确,但当我检查 SharePoint 上的该位置时,该文件不存在。 提前致谢, 克里斯

``Sub PDFActiveSheetNoPrompt()
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strName As String
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
On Error GoTo errHandler

Set wbA = ActiveWorkbook
Set wsA = ActiveSheet

'get active workbook folder, if saved
strPath = wbA.Path
If strPath = "" Then
  strPath = Application.DefaultFilePath
End If
strPath = strPath & "\"

strName = wsA.Range("B1").Value _
          & " - " & wsA.Range("B2").Value _
          & " - " & wsA.Range("B3").Value

'create default name for savng file
strFile = strName & ".pdf"
strPathFile = strPath & strFile

'export to PDF in current folder
    wsA.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=strPathFile, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=False
    'confirmation message with file info
    MsgBox "PDF file has been created: " _
      & vbCrLf _
      & strPathFile

exitHandler:
    Exit Sub
errHandler`:
    MsgBox "Could not create PDF file"
    Resume exitHandler
End Sub

我尝试将 URL 从 https.... 插入最后一个位置后的“/”,插入“StrPath”声明中的文件路径,并插入 wbA.Path 上的“wbA”和“路径”。我不确定我还能在这个宏中将代码更改为什么,而不会在其他地方引起错误。

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    最简单的方法是使目标文件夹在 One Drive 应用程序中可用,然后使用本地路径保存文件。

    【讨论】:

      猜你喜欢
      • 2017-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多