excel 将宏链接到Onedrive

yzxexxkh  于 2023-01-27  发布在  其他
关注(0)|答案(1)|浏览(287)

我正试图将文件宏保存到我的团队的一个驱动器。这是一个有多个用户的轮班报告,我想把一个“保存副本”按钮,所以当我们点击保存它创建一个PDF文件夹中的驱动器,是时间戳与日期,轮班,和主管。下面是我已经能够从教程网站。我有共享驱动器文件夹的URL,我希望这些结束了。我需要一些帮助来确定将其插入的位置。现在,当我运行宏时,它将创建一个提示,其中包含文件名和保存位置。位置看起来正确,但当我在SharePoint上检查该位置时,该文件不存在。提前感谢,Chris

``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”和“path”。我不确定在不引起其他错误的情况下,还可以将此宏中的代码更改为其他什么内容。

kiz8lqtg

kiz8lqtg1#

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

相关问题