Help with VBA code, making it spacific to one workbook

P

polska2180

I have this code....I would like for it to me changed so that it only
effects that one workbook and not any of the ones that are open or
would be open while this is open. TY

Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As
Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long,
ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) _
As Long
Const WS_MINIMIZEBOX = &H20000
Const WS_MAXIMIZEBOX = &H10000
Const GWL_STYLE = (-16)

Sub auto_close()
Dim MyHandle
Dim hWnd As Long
MyCap$ = Application.Caption
hWnd = FindWindowA(vbNullString, MyCap$)
MyHandle = GetSystemMenu(hWnd, 1)
Call RemoveMenu(MyHandle, 6, &H400)
Application.DisplayFormulaBar = True
Application.ScreenUpdating = False
Application.DisplayCommentIndicator = xlNoIndicator
Application.CommandBars("Standard").Visible = True
Application.CommandBars("Formatting").Visible = True
Application.CommandBars("Drawing").Visible = True
Application.CellDragAndDrop = True
Application.CommandBars("Worksheet Menu Bar").Enabled = True
With ActiveWindow
..DisplayHeadings = True
..DisplayHorizontalScrollBar = True
..DisplayVerticalScrollBar = True
..DisplayWorkbookTabs = True
End With
Application.WindowState = xlMaximized
Dim L As Long
L = GetWindowLong(Application.hWnd, GWL_STYLE)
L = SetWindowLong(Application.hWnd, GWL_STYLE, WS_MINIMIZEBOX _
Or WS_MAXIMIZEBOX Or L)

ThisWorkbook.Saved = True
ThisWorkbook.Close True
End Sub
Sub Print_1()
Application.ScreenUpdating = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top