VBA Close Window

MDuff

Well-known Member
Joined
Dec 29, 2002
Messages
529
Office Version
  1. 365
Platform
  1. Windows
Hi all I have been Playing with this simple code And I had a Question Every time the code runs with the part in bold it asks me if I want to save the Changes to the workbook (this work book has links) Is there I way I can have excel say yes or know to this with out having to click on it
Any help is very appreciated

private Sub Workbook_Open()
ActiveSheet.Unprotect Password:="12345"

Workbooks.Open Filename:= _
"\\Crsjofil001\Accounts\GEA\Warranty Management\HR Documents\Performance Appraisals\Performance Appraisals - 2nd Semester 2003\GEA Performance Appraisals Warranty Management II 2003 xls.xls"

ActiveWindow.Close
Windows("PA Summary WM.xls").Activate



ActiveSheet.Protect Password:="12345", DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

thanks Mike
 
As the final lines of the routine run I was getting 2 popup messages.

The first popup was "Do you want to save", which was fixed with the code in blue below

Windows("VLT_iGEM Compare v.2.xlsx").Activate
ActiveWindow.Close False


The second popup was/is "There is a large amount of information on the clipboard, do you want to keep it", which is what I was hoping the last line of code was suposed to answer and close.

Any and all help is greatly appriciated!
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
The code you actually want for that is this:

Code:
Application.CutCopyMode= False
 
Upvote 0
I had tried that earlier, but at the end of the code. Afrer your response I added it after the paste and it worked great
Rich (BB code):
    Range("A:A,B:B,T:T,U:U").Select
    Selection.Copy
    Windows("GLI CHECK.xlsm").Activate
    Worksheets("CURRENT CHECK").Activate
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    
'THIS AUTO FITS ALL COLUMNS
    Cells.Select
    Cells.EntireColumn.AutoFit
'THIS CLOSES COMPARE WORKBOOK
    Windows("VLT_iGEM Compare v.2.xlsx").Close False

End Sub

Thank you RoryA
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,215,492
Messages
6,125,115
Members
449,206
Latest member
burgsrus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top