另存为方法正在为某些用户而非其他用户创建运行时错误
Save As method is creating runtime error for some users not others
我创建了一个命令按钮,它根据电子表格中的信息自动将工作簿保存到两个文件路径之一。这对我来说很好,但我的同事每次都会遇到以下错误。
方法是扩展文件路径并在本例中添加\0BA1700(每次都会更改)。这不会发生在我的电脑上,代码可以正常工作。这是子:
Private Sub CommandButton21_Click()
Dim pathUnder As String
Dim pathOver As String
Dim file As String
file = Range("D2").Value
pathUnder = "G:\Technical Services\LARGE CORPORATE UW\Full Insurance\FI Quote Spreadsheets (below 500)\"
pathOver = "G:\Technical Services\LARGE CORPORATE UW\Full Insurance\FI Quote Spreadsheets (above 500)\"
If Range("D4").Value = "" Or Range("D2").Value = "" Then
MsgBox ("Save Failed. Please ensure there are values in both cells D2 and D4")
Else
If Range("D4").Value >= 500 Then
ActiveWorkbook.SaveAs fileName:=pathOver & file & ".xlsm", FileFormat:=52
Else
ActiveWorkbook.SaveAs fileName:=pathUnder & file & ".xlsm", FileFormat:=52
End If
End If
End Sub
非常感谢帮助。
也许是某种例外?您确定当前没有任何人使用此文件吗?也许你自己的程序呢?
已解决。我同事的计算机没有将 G 驱动器映射到正确的服务器,因此重新映射它,现在可以正常工作了。
方法是扩展文件路径并在本例中添加\0BA1700(每次都会更改)。这不会发生在我的电脑上,代码可以正常工作。这是子:
Private Sub CommandButton21_Click()
Dim pathUnder As String
Dim pathOver As String
Dim file As String
file = Range("D2").Value
pathUnder = "G:\Technical Services\LARGE CORPORATE UW\Full Insurance\FI Quote Spreadsheets (below 500)\"
pathOver = "G:\Technical Services\LARGE CORPORATE UW\Full Insurance\FI Quote Spreadsheets (above 500)\"
If Range("D4").Value = "" Or Range("D2").Value = "" Then
MsgBox ("Save Failed. Please ensure there are values in both cells D2 and D4")
Else
If Range("D4").Value >= 500 Then
ActiveWorkbook.SaveAs fileName:=pathOver & file & ".xlsm", FileFormat:=52
Else
ActiveWorkbook.SaveAs fileName:=pathUnder & file & ".xlsm", FileFormat:=52
End If
End If
End Sub
非常感谢帮助。
也许是某种例外?您确定当前没有任何人使用此文件吗?也许你自己的程序呢?
已解决。我同事的计算机没有将 G 驱动器映射到正确的服务器,因此重新映射它,现在可以正常工作了。