473,801 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I close Windows Explorer using Access VBA

2 New Member
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.Fol lowHyperlink strPathName, , False, False

How do I close Windows Explorer?

Thanks
Aug 22 '07 #1
2 8902
FishVal
2,653 Recognized Expert Specialist
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.Fol lowHyperlink 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 New Member
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 "SendMessag eA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long

Public Declare Function GetWindowThread ProcessId 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
GetWindowThread ProcessId hWnd, lngProcID
If lngProcID = lngParam Then
'Debug.Print hWnd, lngProcID
SendMessage hWnd, WM_CLOSE, 0, 0
End If
End Sub

Public Sub CloseProcess(By Val 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
1312
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 UPDATE values into the comments or titles fields. If someone knows how VB.Net can INSERT or UPDATE column values in windows explorer that will be very helpful. Thanks,
10
38020
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 window? I have to click yes to close the window. How can I close the current window directly without this dialog box? Thank you.
2
13244
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 prefer something a little less drastic. I suspect what I'm going to need is some API call such as SendMessage. Anybody have any suggestions?
1
5501
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 following code after the "Application.Run(new VMSMain());": static void Main() { Application.Run(new VMSMain()); }
2
1901
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 three buttons on a windows form that provide three options for the user the process goes like this user clicks button one and a web service is called that dwnloads a list
1
9240
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 programmatically to the directory and found that the easiest way to refresh the folder is to just open windows explorer. Without doing this, it isn't refreshed in the system. I had the same problem in VB6 and VBA as with VB.net. Searching the newsgroups...
7
5830
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 to be two techniques for earlier versions. But the window.opener='' ;window.close(); and the window.open('','_parent','') ;window.close(); techniques do not work for me. I.e., I still get confirmation message
16
11861
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 that most Windows programs have, so I'm suprised it's not easier to implement in Access/VBA. Through Google, I found two VB6 examples and one VBA example on the Access Web written by Dev Ashish. The VB6 examples used loops to keep checking...
0
2342
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. It seems to hang on the command. When we open the application an peruse the screens without opening up a report (using crystal reports), the application and access db closes fine. But as soon as we run a report and then close the report and...
0
9698
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10292
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10262
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9101
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7589
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6829
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5616
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.