Hello all,
I have a code opening a workbook then creating a copy under a new file name, but whenI go to open the new file, it says it is corrupted. No idea why. Any help would be greatly appreciated.
I have a code opening a workbook then creating a copy under a new file name, but whenI go to open the new file, it says it is corrupted. No idea why. Any help would be greatly appreciated.
VBA Code:
Sub VEDC()
Dim wrkMyWorkBook As Workbook
If Dir(Sheets("Sheet1").Range("B15").Value, vbDirectory) = vbNullString Then
MsgBox "The full path of """ & Sheets("Sheet1").Range("B15").Value & """ doesn't exist!!"
Exit Sub
End If
On Error Resume Next 'Ignore any errors (i.e. if workbook is not open)
Set wrkMyWorkBook = Workbooks(Sheets("Sheet1").Range("B15").Value)
On Error GoTo 0 'Turn error reporting back on
'If the 'wrkMyWorkBook' variable is Nothing then the workbook is not open, therefore we'll...
If wrkMyWorkBook Is Nothing Then
'...open it
Set wrkMyWorkBook = Workbooks.Open(Filename:=Sheets("Sheet1").Range("B15").Value)
End If
'Application.Wait (Now + TimeValue("0:0:30"))
ActiveWorkbook.SaveAs Filename:=Workbooks("Daily Reports - Copy.xlsm").Worksheets("Sheet1").Range("B16").Value, FileFormat:=xlWorkbookNormal
'Set wrkMyWorkBook = ActiveWorkbook.SaveAs(Filename:=Sheets("Sheet1").Range("B16").Value)
End Sub