Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Function GetActiveWindow Lib "user32"

Hi everyone
When we use this Windows API, the default "Folder" (it's not really a folder) that is selected in the window that appears is the user's workstation. Is there a way to change that default value to a known folder or to a specific path so that the user does not have to click many times to reach the desired path
I do not include any code, but it is all available if any one needs it. You just have to ask for it
Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Function GetActiveWindow Lib "user32"

Hi Jac,

You have a few options here. If you want to be able to specify the initial
folder, you can automate the Shell interface to do it:

Sub test()
Dim sh As Object
Dim fol As Object
Dim fi As Object

Set sh = CreateObject("Shell.Application")

Set fol = sh.BrowseForFolder(Application.Hwnd, _
"Select Folder", 0, "C:\")

If Not fol Is Nothing Then
Set fi = fol.ParentFolder.ParseName(fol.Title)
If Not fi Is Nothing Then
MsgBox fi.Path
Else
MsgBox fol.Title
End If
Set fol = Nothing
Else
MsgBox "no folder selected"
End If
End Sub

Alternatively, you can utilize the API using Jim Rech's Browse For Folder
utility:

http://bmsltd.ie/MVP/Default.htm (look for BrowseForFolder.zip under Jim
Rech's name)

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Jac Tremblay wrote:
Hi everyone,
When we use this Windows API, the default "Folder" (it's not really a
folder) that is selected in the window that appears is the user's
workstation. Is there a way to change that default value to a known
folder or to a specific path so that the user does not have to click
many times to reach the desired path. I do not include any code, but
it is all available if any one needs it. You just have to ask for it.
Thank you.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Function GetActiveWindow Lib "user32"

Hi Jake,
That is very interesting. I tried your code and it's rather straight forward. But how come one does not have to declare something like "Private Declare Function GetActiveWindow Lib "user32" () As Long" in the screen window code declaration section?
Another question: Why, when I create a new folder, I can specify its new name only at the root? If not at the root, the folder gets automatically the name "New Folder" with no feed back.
I will now check out Jim Rech's application.

Thank you very much.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Function GetActiveWindow Lib "user32"

Hi Jac,

Jac Tremblay wrote:
That is very interesting. I tried your code and it's rather straight
forward. But how come one does not have to declare something like
"Private Declare Function GetActiveWindow Lib "user32" () As Long" in
the screen window code declaration section?


This code is automating the Shell - it is not calling API functions (such as
GetActiveWindow) directly.

Another question: Why,
when I create a new folder, I can specify its new name only at the
root? If not at the root, the folder gets automatically the name "New
Folder" with no feed back.


I'm not sure what you're referring to here. Keep in mind that we can't see
your code unless you post it. <g

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Function GetActiveWindow Lib "user32"

Hi Jake
My question and your answer were
Another question: Why
when I create a new folder, I can specify its new name only at th
root? If not at the root, the folder gets automatically the name "Ne
Folder" with no feed back


I'm not sure what you're referring to here. Keep in mind that we can't se
your code unless you post it. <g

I now tell you that I have no more problem regarding this functionality. I can browse for a folder using the Shell Automation like you showed in your previous answer. I can create a new folder at the root or elsewhere and give it any name I want
The reason why I did not include any code is that I refered to your own code published in the previous answer
Thank you for providing me with this simple and easy way of browsing for a folder. It will be very useful
Thanks too for your precious time
Ja


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text "comparison" operator for "contains" used in an "IF" Function Pawaso Excel Worksheet Functions 4 April 4th 23 11:35 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
inserting a conditional "go to" command on a excel "if" function velasques Excel Worksheet Functions 5 March 10th 06 08:16 PM


All times are GMT +1. The time now is 09:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"