jasonfish11
Board Regular
- Joined
- May 14, 2015
- Messages
- 56
Hi,
I have a macro that winds up creating a new workbook based on some templates I have. There is some issues using these in Chrome, so I've added a warning at the beginning when a workbook is opened. Currently the warning appears twice, once when the 1st workbook is opened "Associate Movement Workbook" and once when the template is opened variable of "MainWB" in coding.
I want to get rid of one of the warnings, but to do so I need the template coding to close both workbooks without saving if the user selects the "Leave" button (indicating they are using Chrome).
The coding I have if I only have the MainWB open will close the MainWB. If I have both WB's open (how the user will experience it) then the macro will find and close the "Associate Movement Workbook" but does not close "MainWB". I can't figure out why this happens. Any help will be much appreciated.
Thank you in advance.
I have a macro that winds up creating a new workbook based on some templates I have. There is some issues using these in Chrome, so I've added a warning at the beginning when a workbook is opened. Currently the warning appears twice, once when the 1st workbook is opened "Associate Movement Workbook" and once when the template is opened variable of "MainWB" in coding.
I want to get rid of one of the warnings, but to do so I need the template coding to close both workbooks without saving if the user selects the "Leave" button (indicating they are using Chrome).
The coding I have if I only have the MainWB open will close the MainWB. If I have both WB's open (how the user will experience it) then the macro will find and close the "Associate Movement Workbook" but does not close "MainWB". I can't figure out why this happens. Any help will be much appreciated.
VBA Code:
Private Sub UserForm_Initialize()
ContinueCommand.SetFocus
End Sub
Private Sub LeaveCommand_Click()
Dim WB As Workbook
Dim MainWB As Workbook
Set MainWB = ActiveWorkbook
For Each WB In Workbooks
If WB.Name = "Associate Movement Workbook.xlsm" Then
WB.Close SaveChanges:=False
End If
Next
MainWB.Close SaveChanges:=False
Unload ChromeWarning
End Sub
Thank you in advance.