我已经在许多不同的工作簿中使用了该代码,但由于某种原因,每当我试图在新的工作簿项目中运行该代码时,都会出现错误37。
Public Sub SaveAsA1()
Range("C9").Value = Application.UserName
Set rRng = Sheet1.Range("C8")
If IsEmpty(rRng.Value) Then
MsgBox ("Cell (C8) is empty. Please scan in the correct work order number into (C8)")
End
Else
End If
Dim Result As Integer
Result = MsgBox("Are you sure you want to save?", vbQuestion + vbYesNo)
If Result = vbYes Then
MsgBox "\\us.\TEST_DATA\MODULE\" & "WO_" & Range("C8")
Else
End
End If
'Variable declaration
Dim sFolderPath As String
Dim oFSO As Object
'Define Folder Path
sFolderPath = "Now saving to \\us.\TEST_DATA\MODULE\" & "WO_" & Range("C8")
'Create FSO Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
'Check Specified Folder exists or not
If oFSO.FolderExists(sFolderPath) Then
'If Folder is available
Else
'If folder is not available
MkDir sFolderPath '<-------------Run time error 76
End If
我希望创建一个新的文件夹,如果一个不存在。我删除了MkDir代码,它的工作,但现在我没有一个IF协议。
1条答案
按热度按时间jvidinwx1#
修正了!!!现在保存到应该在上面的消息框中是这个问题。