473,433 Members | 1,851 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,433 software developers and data experts.

How do I close Windows Explorer using Access VBA

2
I have a form that allows users to open Windows Explorer and view folders based on a list of path names.

I want to create code that will close all or a specific Windows Explorer screen.

I used this line to open the Windows Explorer

Application.FollowHyperlink strPathName, , False, False

How do I close Windows Explorer?

Thanks
Aug 22 '07 #1
2 8813
FishVal
2,653 Expert 2GB
I have a form that allows users to open Windows Explorer and view folders based on a list of path names.

I want to create code that will close all or a specific Windows Explorer screen.

I used this line to open the Windows Explorer

Application.FollowHyperlink strPathName, , False, False

How do I close Windows Explorer?

Thanks
Hi, jercha.

If you will manage to run WinExplorer via "Shell" function, then the following will be useful for you
Close a Program
Aug 22 '07 #2
jercha
2
Hi, jercha.

If you will manage to run WinExplorer via "Shell" function, then the following will be useful for you
Close a Program

Your notepad program worked for notepad but not for explorer.
How do I fix?

I replaced notepad with explorer but the CloseProcess failed to close the explorer screen:


Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long

Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As Long, ByRef lpdwProcessId As Long) As Long


Public Declare Function EnumWindows Lib "user32" _
(ByVal fpCallback As Long, ByVal lParam As Long) As Long

Public Const WM_CLOSE = 16

Public Sub RunAndCloseApp()
Dim lngProcID As Long
lngProcID = Shell("explorer")
MsgBox "Explorer started, Ok to close it", vbOKOnly, "Close App"
CloseProcess lngProcID
End Sub

Public Sub clbEnumWindows(ByVal hWnd As Long, ByVal lngParam As Long)
Dim lngProcID As Long
GetWindowThreadProcessId hWnd, lngProcID
If lngProcID = lngParam Then
'Debug.Print hWnd, lngProcID
SendMessage hWnd, WM_CLOSE, 0, 0
End If
End Sub

Public Sub CloseProcess(ByVal lngProcID)
EnumWindows AddressOf clbEnumWindows, lngProcID
End Sub

Aug 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: MAFDoit | last post by:
NEWSGROUP: This is a followup to the post below. The original post was helpful and I now know many ways to RETRIEVE information from Windows explorer, but I haven't yet found a way to INSERT or...
10
by: Shang Wenbin | last post by:
Hi, When I want to close the current window using window.close() in IE6.0, there will be a confirm box that: The web page you are viewing is trying to close the window. Do you want to close this...
2
by: Paul Steele | last post by:
Is there any way to check for open Explorer windows and if any are found, tell Windows Explorer to close them. I don't want a brute force method of killing Explorer and letting it restart. I'd...
1
by: Alpha | last post by:
I have a Window based application that shows up still running in the task manager when I close it. It reaches the "this.close" statement and then it stops at the "}" at the section of the...
2
by: Bruce Wiebe | last post by:
hi all im having a problem accessing a text file on my hard disk after ive created it and added some text to it it would appear that the file is still locked. What happens is this i have...
1
by: Mike Kober | last post by:
I'm having difficulty getting this to work. Any help would be appreciated. What I'm trying to do is to open Explorer onto the Windows/fonts directory and then close it. I've added a font...
7
by: Toccoa | last post by:
After considerable googling - I mean searching with Google(r) - I could not find javascript on a button or <a href=... to close a window in the latest versions of IE and FireFox. There seemed...
16
by: John | last post by:
I am looking for VBA code that will work with Access 2003 to enable dragging and dropping a file/folder name from Windows XP Explorer into an Access form's text box. This is a common functionality...
0
by: Mark Gold | last post by:
Hi! We have a VB application using Crystal Reports 6 that has worked successfully on hundreds of systems for over 10 years. Now, on one network, the application and access database does not close....
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.