将Excel文件的副本保存到SharePoint

时间:2018-12-20 05:54:26

标签: excel vba

我想使用SaveCopyAs而不是SaveAs函数来保持原始文件打开。

Private Sub CommandButton6_Click()

Dim strName As String

Set wbA = ActiveWorkbook
Set wsA = ActiveSheet
strName = wsA.Range("B5").Value
Worksheets("Sheet1").Unprotect Password:=XXXXXX
 If ActiveSheet.CheckBoxes.Count > 0 Then
    ActiveSheet.CheckBoxes.Visible = True
    ActiveSheet.CheckBoxes.Enabled = False
End If
Worksheets("Sheet1").CommandButton6.Visible = False
Worksheets("Sheet1").Protect Password:=XXXXXX
ThisWorkbook.SaveCopyAs Filename:="http://XXXXsharepoint pathXXX" & "/" & 
strName & ".xlsm"

    Worksheets("Sheet1").Unprotect Password:=XXXXXX
    Worksheets("Sheet1").CommandButton6.Visible = False
Worksheets("Sheet1").Protect Password:=XXXXXX

End Sub

上面的代码给我一个1004错误。

0 个答案:

没有答案