Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Start Windows Explorer from Excel

I need to create a spreadsheet with a list of folders (in A2 and below plus
other information) and start Windows Explorer to a specific folder (relevant
to the current cursor row) from within the sheet, at the click of a button.

My main problem is how to "call" the Windows Explorer with an initial folder
parameter (ok, that's easy I think) from the button code.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Start Windows Explorer from Excel

Try something like

Shell "explorer.exe c:\somefolder"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"DoctorG" wrote in message
...
I need to create a spreadsheet with a list of folders (in A2 and
below plus
other information) and start Windows Explorer to a specific
folder (relevant
to the current cursor row) from within the sheet, at the click
of a button.

My main problem is how to "call" the Windows Explorer with an
initial folder
parameter (ok, that's easy I think) from the button code.

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Start Windows Explorer from Excel

If your folder name has spaces, use something like

Shell "explorer.exe ""C:\some folder"""


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Chip Pearson" wrote in message
...
Try something like

Shell "explorer.exe c:\somefolder"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"DoctorG" wrote in message
...
I need to create a spreadsheet with a list of folders (in A2
and below plus
other information) and start Windows Explorer to a specific
folder (relevant
to the current cursor row) from within the sheet, at the click
of a button.

My main problem is how to "call" the Windows Explorer with an
initial folder
parameter (ok, that's easy I think) from the button code.

Thanks





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Start Windows Explorer from Excel

Hi DoctorG

Try this

Shell "explorer.exe C:\Data\", vbNormalFocus


--
Regards Ron de Bruin
http://www.rondebruin.nl


"DoctorG" wrote in message ...
I need to create a spreadsheet with a list of folders (in A2 and below plus
other information) and start Windows Explorer to a specific folder (relevant
to the current cursor row) from within the sheet, at the click of a button.

My main problem is how to "call" the Windows Explorer with an initial folder
parameter (ok, that's easy I think) from the button code.

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Start Windows Explorer from Excel

Thank you both. Ron's addition was helpful as well since the window opened
but got no focus.

Is there an easy way (??!!) to traverse a folder structure and place the
results (filenames) in a vertical range?

"DoctorG" wrote:

I need to create a spreadsheet with a list of folders (in A2 and below plus
other information) and start Windows Explorer to a specific folder (relevant
to the current cursor row) from within the sheet, at the click of a button.

My main problem is how to "call" the Windows Explorer with an initial folder
parameter (ok, that's easy I think) from the button code.

Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Start Windows Explorer from Excel

You may not even need Windows Explorer. You just need a tiny .bat file to:

1. change directory to the one of interest
2. do something like dir *.* file.txt

The .bat file can also be executed by a SHELL command
One the .txt file is created, then the VBA code can directly open and read it.
--
Gary''s Student


"DoctorG" wrote:

Thank you both. Ron's addition was helpful as well since the window opened
but got no focus.

Is there an easy way (??!!) to traverse a folder structure and place the
results (filenames) in a vertical range?

"DoctorG" wrote:

I need to create a spreadsheet with a list of folders (in A2 and below plus
other information) and start Windows Explorer to a specific folder (relevant
to the current cursor row) from within the sheet, at the click of a button.

My main problem is how to "call" the Windows Explorer with an initial folder
parameter (ok, that's easy I think) from the button code.

Thanks

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Start Windows Explorer from Excel

This might actually work. If I can get to understand Jim's code though it
will be better for my Excel knowledge. I am quite familiar with DOS and batch
files since my early days. If I can manage this the new way it will be best.

Thanks
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Start Windows Explorer from Excel

Here is some code for you to try. You need to reference it to the "Microsoft
Scripting Runtime". In the VBE Tools - References and check the appropriate
item.

Sub ListFiles()
'Must reference "Microsoft Scripting Runtime" library

Dim fso As New FileSystemObject
Dim oCurrentFile As File
Dim oCurrentFolder As Folder
Dim wks As Worksheet
Dim rng As Range

Set wks = Sheets("Sheet1")
Set rng = wks.Range("A2")

Set oCurrentFolder = fso.GetFolder("C:\")
On Error Resume Next
For Each oCurrentFile In oCurrentFolder.Files
rng.Value = oCurrentFile.Name
rng.Offset(0, 1).Value = oCurrentFile.ShortName
rng.Offset(0, 2).Value = oCurrentFile.Path
rng.Offset(0, 3).Value = oCurrentFile.DateCreated
rng.Offset(0, 4).Value = oCurrentFile.DateLastAccessed
rng.Offset(0, 5).Value = oCurrentFile.DateLastModified
rng.Offset(0, 6).Value = oCurrentFile.Size
rng.Offset(0, 7).Value = oCurrentFile.Type
rng.Offset(0, 8).Value = oCurrentFile.Attributes
Set rng = rng.Offset(1, 0)
Next oCurrentFile
End Sub

--
HTH...

Jim Thomlinson


"DoctorG" wrote:

Thank you both. Ron's addition was helpful as well since the window opened
but got no focus.

Is there an easy way (??!!) to traverse a folder structure and place the
results (filenames) in a vertical range?

"DoctorG" wrote:

I need to create a spreadsheet with a list of folders (in A2 and below plus
other information) and start Windows Explorer to a specific folder (relevant
to the current cursor row) from within the sheet, at the click of a button.

My main problem is how to "call" the Windows Explorer with an initial folder
parameter (ok, that's easy I think) from the button code.

Thanks

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Start Windows Explorer from Excel

Jim,

Your code has done most of what I need to do, which is to read the file
contents of a folder. Yet it doesn't "see" folders. I guess I haven't been
able to understand yet (I hope) the object-class-method approach. Perhaps if
I see the modifications to handle folders I can make the connection.

Thanks again for your help
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Start Windows Explorer from Excel

Thanks everyone, consider this closed. I just bumped on "Scan A Directory",
dated 9/9/2005 which deals with exactly the same matter. No need to say the
same things over and over.


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
Excel 2007 & Windows Explorer JWhitehead Excel Discussion (Misc queries) 0 June 3rd 09 08:37 PM
windows explorer to excel barrfly Excel Discussion (Misc queries) 2 July 27th 05 04:28 PM
Windows Explorer maximizes over XL 2000, if opened w/ explorer bill Excel Discussion (Misc queries) 2 June 28th 05 02:53 PM
Store data from Windows Explorer in Excel gizmo Excel Worksheet Functions 2 January 8th 05 02:23 AM
Use Windows Script to run Windows Explorer Search? Ian Elliott[_3_] Excel Programming 0 January 12th 04 05:03 PM


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

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

About Us

"It's about Microsoft Excel"