|
-
Jul 10th, 2004, 02:30 PM
#1
Thread Starter
Lively Member
Excel 97, CLOSE ALL FILES but...
Question:
Using Excel 97, I have several workbooks open.
My program takes control of excel, removing user access to all menus, shortcuts, etcs. The only means of closing the program that i leave them is the X on the top right corner.
We are experimenting to find a way to close all "my" open files.
Currently, we use DisplayAlerts= false, and Application.quit
with each file of my program saving automically with no user input required.
BUT *There's always a BUT.
a) if there are no open files from my program, close the application, using application.quit
b) if the user had files open prior, to close all my files, but to leave the user in Excel
Any suggestions on how to accomplish this?
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Jul 10th, 2004, 11:11 PM
#2
Hey FIDDLER, been a while. The only things I could think of right
away was to create some kind of running list of open workbooks
when your program starts. The upon quit, loop through the
workbooks collection checking to see if any of those are open. If
so prompt to save them or ???
The other thing I was thinking was to add some other kind of
hidden property in all of your workbooks. Then upon close if the
workbook doesnt have the property, prompt for save or ???
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 12th, 2004, 08:04 PM
#3
Thread Starter
Lively Member
AHHH!! THis is my third time trying to post tonight! I keep losing my post and getting a message saying that I am not logged in.
Actually, What I am trying to do is disable the WIndow.Close X on the top right corner so that I can force a close only via an Exit button that I will place on the form.
I can identify my open workbooks fairly simple. They all start with the same characters for the workbook name, so I can simply read through the workbook collection looking for them. Or I can add them to a list array as they are opened, and loop through this list array with a close command.
Then my code will be something like this:
For each workbook in myworkbooks
myworkbooks.close (simple to do, since I opened them)
Next
If workbooks.count >1 then
leave excel open
Else
Application.quit
End if
So any suggestions on how to disable or to take control of the Windows CLose Program X. Ideally, I would like this code to be activated by the X and me not having to code a separate Exit button, but I think it's easier to disable the X and write my own exit button.
btw: want to see something neat?
CHeck out my post to Classic VB Forums several days ago. We spent hours trying to find the error in the code. Neat little compiler glitch.
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Jul 12th, 2004, 08:06 PM
#4
Thread Starter
Lively Member
I should mention that there is no user access to any of the menu bars, save the Windows bar (Minimize, Maximize and Close).
Coding it would be a lot simpler is the File Close X would showing. I am trying to do this using the Windows X, or a button that calls the same file.close as the file close X would.
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Jul 12th, 2004, 10:13 PM
#5
I'm not too sure which way you need this, but here is an example
that will remove the cose system menu, thereby disabling the 'x'.
This is for VB and not too sure if can be converted to Excel since I
currently don't have Office on my new system.
VB Code:
Private Const MF_BYPOSITION = &H400&
Private Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Sub Form_Load()
RemoveMenu GetSystemMenu(hwnd, 0), 6, MF_BYPOSITION
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormCode Then Cancel = True
End Sub
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|