breynolds0431
Active Member
- Joined
- Feb 15, 2013
- Messages
- 303
- Office Version
- 365
- 2016
- Platform
- Windows
I've seen this issue on some other posts/sites, but nothing that ever looked to be resolved. Basically, I have a file that need to copy certain tabs to a pre-existing workbook (now that I think about it, this could be a new workbook), then saves the file with the same filename plus the save date appended to the end of the file name. The issue is that when it gets to the save-as step, the "saving" dialog displays and makes some progress but doesn't close on it's own. I need to manually click the "Cancel" button for the dialog to close. Then, the macro starts back up on it's own - also weird.
Below is the code I'm attempting. Any help would be greatly appreciated...
Below is the code I'm attempting. Any help would be greatly appreciated...
VBA Code:
Sub SheetMove()
Application.StatusBar = "Moving Sheets . . . "
Dim ws As Worksheet
Dim wst As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Workbooks.Open ("\\[LAN location]\[filename1].xlsx")
Workbooks.Open ("\\[LAN location]\[filename1].xlsx")
For Each ws In ThisWorkbook.Worksheets
Select Case ws.Name
Case "Tab1-w", "Tab2-w", "Tab3-w", "Tab4-w", "Tab5-w"
Case Else
With Workbooks("[file2name].xlsx")
ws.copy After:=.Sheets(.Sheets.Count)
End With
End Select
Next
For Each wst In ThisWorkbook.Worksheets
Select Case wst.Name
Case "Tab1-x", "Tab2-x", "Tab3-x", "Tab4-x", "Tab5-x"
Case Else
With Workbooks("[file1name].xlsx")
wst.copy After:=.Sheets(.Sheets.Count)
End With
End Select
Next
Windows("[file1name].xlsx").Activate
ActiveWorkbook.SaveAs Filename:="\\[LAN location]\[filename1] - " _
& Format(Date, "yyyymmdd") & ".xlsx", FileFormat:=51, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
Windows("[file1name].xlsx").Activate
ActiveWorkbook.Close SaveChanges:=False
If Application.Dialogs(xlDialogSaveAs).Show Then
Else
End If
Windows("[file1name].xlsx").Activate
ActiveWorkbook.Close SaveChanges:=False
Windows("[file2name].xlsx").Activate
ActiveWorkbook.SaveAs Filename:="\\[LAN location]\[filename2] - " _
& Format(Date, "yyyymmdd") & ".xlsx", FileFormat:=51, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
Windows("[file2name].xlsx").Activate
ActiveWorkbook.Close SaveChanges:=False
If Application.Dialogs(xlDialogSaveAs).Show Then
Else
End If
Windows("[file2name].xlsx").Activate
ActiveWorkbook.Close SaveChanges:=False
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.StatusBar = ""
MsgBox "Good news! The *** Workbooks have been updated and saved to their respective folders on the LAN."
End Sub