I'm using the ImportZippedFile to unzip files from within my Access application, however I've run into a problem that I don't know if I can fix.
In the ImportZippedFile it looks for the extension of the file in order to unzip the it. I had a client that the extension in windows was turned off so the unzip didn't work. I'm wondering is there a way to turn file extensions on from within my application. If you need the full code for the ImportZippedFile let me know and I'll post it.
Thanks for any help.
- This one is a little tricky, Tom. You can accomplish this by using the WshShell Object which enables you to interact with various aspects of the Windows Shell.
- The Logic is as follows:
- You must query a specific Registry Key is see if the Hide extensions for known file types is ON or OFF (1 or 0). You can use the RegRead() Method of the WshShell Object.
- If this Option is ON (1), then you must turn it OFF via the RegWrite() Method of the WshShell Object.
- After enabling File Extension and performing your operations(s), you may wish to return it to its prior state.
- Enough rambling on, the Code to do this is listed below:
- Dim WshShell As Object
-
Dim strRegKey As String
-
-
strRegKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt"
-
-
Set WshShell = CreateObject("WScript.Shell")
-
-
If WshShell.RegRead(strRegKey) Then
-
WshShell.RegWrite strRegKey, 0, "REG_DWORD"
-
End If
- Good Luck with your Project.
15 2227 NeoPa 32,556
Expert Mod 16PB
Can you be a little more precise. I know of configuring extensions but 'turning them on' means nothing to me.
This may help.
Basically I think you have to change
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\Advanced registry subkey.
In the registry.
There are lots of examples of how to do this on the web.
Phil
- This one is a little tricky, Tom. You can accomplish this by using the WshShell Object which enables you to interact with various aspects of the Windows Shell.
- The Logic is as follows:
- You must query a specific Registry Key is see if the Hide extensions for known file types is ON or OFF (1 or 0). You can use the RegRead() Method of the WshShell Object.
- If this Option is ON (1), then you must turn it OFF via the RegWrite() Method of the WshShell Object.
- After enabling File Extension and performing your operations(s), you may wish to return it to its prior state.
- Enough rambling on, the Code to do this is listed below:
- Dim WshShell As Object
-
Dim strRegKey As String
-
-
strRegKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt"
-
-
Set WshShell = CreateObject("WScript.Shell")
-
-
If WshShell.RegRead(strRegKey) Then
-
WshShell.RegWrite strRegKey, 0, "REG_DWORD"
-
End If
- Good Luck with your Project.
Well that works sometimes, I don't know why. Here's what I did, I went into Explorer and turned off the file extension. Then I ran my program and your code turned the file extension On, I have your code in the ImportZippedfile routing at the very beginning. I still get the unzip problem because the extension is still off. When I look in the Windows Explorer I see that the file extension is turned On but the file extension of the files don't show. If I turn the file extension off and then on again it works.
Any ideas what I'm doing wrong.
You probably need to kill and restart the explorer process.
A simple Refresh of the Explorer Window (F5) should do the trick. There should be no need to close and re-open Explorer, I think (LOL).
is there a way to do a refresh from with the Access VBA.
You would probably have to retrieve the Window Handle of Windows Explores and send it a Message to Close. Will look into this tomorrow if I have a chance.
Thanks, looking forward to seeing how this could be done.
- This was a little tougher than I realized, but I do believe that I have come up with a solution. It involves the following Steps:
- If Hide file extensions is turned ON, then Reset this Option to OFF.
- Find the Explorer Window and retrieve it's Handle.
- MAXIMIZE the Explorer Window.
- Send the F5 Keystroke (Refresh) to the Explorer Window.
- Required Declarations:
- Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
-
Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As LongPtr, ByVal nCmdShow As Long) As Long
-
Public Const SW_SHOWMAXIMIZED = 3
- Code Definition:
- Dim WshShell As Object
-
Dim strRegKey As String
-
Dim lngHnd As LongPtr
-
Dim lngRetVal As Long
-
-
strRegKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt"
-
-
Set WshShell = CreateObject("WScript.Shell")
-
-
If WshShell.RegRead(strRegKey) Then
-
WshShell.RegWrite strRegKey, 0, "REG_DWORD" 'Enable File Extensions
-
-
lngHnd = FindWindow("CabinetWClass", vbNullString) 'Find Windows Explorer
-
lngRetVal = ShowWindow(lngHnd, SW_SHOWMAXIMIZED) 'MAXIMIZE Windows Explorer
-
-
WshShell.SendKeys "{F5}" 'Pass the F5 Key to Windows Explorer
-
End If
-
-
Set WshShell = Nothing
This would seem to work except I get an error on the LongPtr do I need some new reference?
I still can't get this to work here's the code - Dim WshShell as Object
-
Dim strRegKey as String
-
Dim lngHnd As longPtr
-
dim lngRetVal as long
-
-
strRegKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt"
-
Set WshShell = CreateObject("WScript.Shell")
-
If WshShell.RegRead(strRegKey) then
-
WshShell.RegWrite strRegKey, 1, "REG_DWORD"
-
lngHnd = FindWindow("CabinetWClass", vbNullString)
-
lngRetVal = ShowWindow(lnghnd, SW_SHOWMAXIMIZED)
-
WshShell.Sendkeys "(F5)"
-
endif
-
Set WshShell = nothing
-
-
I have set the extension in Explorer to 0 manually to test this
As I walk through the program (F8) it seems to go through everything until I get to the WshShell.SendKeys "(F5)" that command just writes a F5 on the next line of the code. If I look at the options in Explorer the hideFileExt still shows 0. No change.
I also get an error on the LongPtr I've changed it to just Long
I'm about ready to give up on this.
What do you think.
The correct Syntax for SendKeys is
not
Let me know how this works out, we're almost there. It works fine on my end, so must be a small adjustment on yours.
Well that was some difference I didn't notice the difference at first and was about to tell you it didn't work. when I looked closer I could see they were not ( but { when I made that change it worked. Thank you so much.
You are quite welcome, Tom. This was a tough one, gonna take a break now (LOL).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Terence |
last post by:
A curious observation:
I have my apache web server configured for the PHP apache module to
parse files ending in the .php extension.
nothing unusual about that, but I also noticed that if I...
|
by: knutsample |
last post by:
Hello!
I'm trying to associate a file extension to my wxPython script so that
all I have to do is double click on the file and my python script will
load up with the path of that file.
For...
|
by: bailee220 |
last post by:
I have included the following code to open an Access database form from
within an exsisting Access database. But when I run the code, it
appears that it opens the database because in windows...
|
by: Les Desser |
last post by:
In A97 I am trying to determine some attributes of files in a folder -
Date, time, file size and file name.
To this end I have managed to create a batch file to do a Dir to a work
file (and then...
|
by: David |
last post by:
Should you be able to map a any file extension to the ASP.NET dll and
have it execute ASP.NET script, just like an .aspx page, when it is
requested by a browser. If not, why bother giving us the...
|
by: Brett Romero |
last post by:
I'm trying to associate a file extension to a program I've created. I
have
browsed for the program in Windows Explorer | Tools | Options and set
it there. However, Windows always keeps Notepad...
|
by: JDeats |
last post by:
When a user double clicks on file item in Windows Explorer, Windows
tries to open the document with whatever application is related to
it's file extension.
In my WinForms application I would...
|
by: dazzler |
last post by:
I need to open PDF file with my python application, and I'm using os.startfile(filename.pdf) command, I would need open command act 100% like clicking the file in the windows explorer
python...
|
by: argonautical |
last post by:
We are using some Access databases in v2003 format where the file extension is not the default .mdb. We've customized the extension and have registered that with Access so it will open when...
|
by: accessnewbie90 |
last post by:
I tried to run SoundRecorder.exe (located in C:\Windows\System32\SoundRecorder.exe) in windows 7 using a command box in access but for some strange reason I get a Run time 53 error saying that the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |