ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Foldr Macro..? (https://www.excelbanter.com/excel-programming/421915-open-foldr-macro.html)

Andrew[_9_]

Open Foldr Macro..?
 
Is there an easy Macro to open Folders from Excel.VB..?
I'm Sure Ive done it before - but can't remember if it was a fs
object or something.

Thx for any Help/Feedback



JLGWhiz

Open Foldr Macro..?
 
This is out of the VBA help file. It opens a folder and returns info on the
filename included as folderspec.

Sub ShowFolderInfo(folderspec)
Dim fs, f, s,
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
s = f.DateCreated
MsgBox s
End Sub



"Andrew" wrote:

Is there an easy Macro to open Folders from Excel.VB..?
I'm Sure Ive done it before - but can't remember if it was a fs
object or something.

Thx for any Help/Feedback




Andrew[_9_]

Open Foldr Macro..?
 
Brilliant - Thanx..It was the CreateObject- Bit I'd Forgot.

Sorry, Should of explained more clearly.
I was wanting to Open(Explore) the Folder. in a new Window.

Any Ideas..?



"JLGWhiz" wrote in message
...
| This is out of the VBA help file. It opens a folder and returns
info on the
| filename included as folderspec.
|
| Sub ShowFolderInfo(folderspec)
| Dim fs, f, s,
| Set fs = CreateObject("Scripting.FileSystemObject")
| Set f = fs.GetFolder(folderspec)
| s = f.DateCreated
| MsgBox s
| End Sub
|
|
|
| "Andrew" wrote:
|
| Is there an easy Macro to open Folders from Excel.VB..?
| I'm Sure Ive done it before - but can't remember if it was a fs
| object or something.
|
| Thx for any Help/Feedback
|
|
|



JLGWhiz

Open Foldr Macro..?
 
You would use this particular code like a function. In a separate sub you
would enter a statement like:

ShowFolderInfor("MyFile.xls")

Which would then produce the date the file was created. See the GetFolder
page in VBA help for more info.

"Andrew" wrote:

Is there an easy Macro to open Folders from Excel.VB..?
I'm Sure Ive done it before - but can't remember if it was a fs
object or something.

Thx for any Help/Feedback




Andrew[_9_]

Open Foldr Macro..?
 
.... Just used a - Hyperlink - in the End.
Imp Tink i used an "Execute shell folder" or something ages ago..!
<That'll Bug me now.. ¦-(
Thanx again,
A

"JLGWhiz" wrote in message
...
| You would use this particular code like a function. In a separate
sub you
| would enter a statement like:
|
| ShowFolderInfor("MyFile.xls")
|
| Which would then produce the date the file was created. See the
GetFolder
| page in VBA help for more info.
|
| "Andrew" wrote:
|
| Is there an easy Macro to open Folders from Excel.VB..?
| I'm Sure Ive done it before - but can't remember if it was a fs
| object or something.
|
| Thx for any Help/Feedback
|
|
|



Kenneth Hobson[_3_]

Open Foldr Macro..?
 
To explore or just select and return selection? If the first, one these
methods will work.

Sub OpenExplorer()
Dim x As Variant
Dim sPath As String

'sPath = """E:\MyDirectory\Williams,Bob 7264\"""
sPath = Application.path
x = Shell("explorer /n,/e," & sPath, 1)
End Sub

Sub t()
Dim sPath As String
sPath = """E:\MyDirectory\Williams,Bob 7264\"""
IExplorerOpen sPath
End Sub

Private Sub IExplorerOpen(sPath As String)
'early binding. Requires reference to Microsoft Internet Controls
(shdocvw.dll).
Dim ieo As SHDocVw.InternetExplorer
Set ieo = New SHDocVw.InternetExplorer
ieo.FullScreen = True
ieo.Navigate sPath
ieo.Visible = True
Exit Sub

'late binding
Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
IE.Navigate sPath
IE.Visible = True
Exit Sub
End Sub


Steve Yandl[_2_]

Open Foldr Macro..?
 
Andrew,

I suspect you want to be able to select files from this new Explore window
and do something with them. If you simply want to open an explorer window,
here is one approach, in this case opening the folder C:\Test.

Set objShell = CreateObject("Shell.Application")
objShell.Explore "C:\Test"
Set objShell = Nothing



Steve Yandl



"Andrew" wrote in message
...
Brilliant - Thanx..It was the CreateObject- Bit I'd Forgot.

Sorry, Should of explained more clearly.
I was wanting to Open(Explore) the Folder. in a new Window.

Any Ideas..?



"JLGWhiz" wrote in message
...
| This is out of the VBA help file. It opens a folder and returns
info on the
| filename included as folderspec.
|
| Sub ShowFolderInfo(folderspec)
| Dim fs, f, s,
| Set fs = CreateObject("Scripting.FileSystemObject")
| Set f = fs.GetFolder(folderspec)
| s = f.DateCreated
| MsgBox s
| End Sub
|
|
|
| "Andrew" wrote:
|
| Is there an easy Macro to open Folders from Excel.VB..?
| I'm Sure Ive done it before - but can't remember if it was a fs
| object or something.
|
| Thx for any Help/Feedback
|
|
|





Andrew[_9_]

Open Foldr Macro..?
 
Hail the Messiah...
Shell "Explorer /e,MyDocuments", vbNormalFocus

That's the one.. Shell.

Silly me, for the life of me could not remember.
I'll sleep tonight.
Thx Kenneth.

"Kenneth Hobson" wrote in message
...
| To explore or just select and return selection? If the first, one
these
| methods will work.
|
| Sub OpenExplorer()
| Dim x As Variant
| Dim sPath As String
|
| 'sPath = """E:\MyDirectory\Williams,Bob 7264\"""
| sPath = Application.path
| x = Shell("explorer /n,/e," & sPath, 1)
| End Sub
|
| Sub t()
| Dim sPath As String
| sPath = """E:\MyDirectory\Williams,Bob 7264\"""
| IExplorerOpen sPath
| End Sub
|
| Private Sub IExplorerOpen(sPath As String)
| 'early binding. Requires reference to Microsoft Internet Controls
| (shdocvw.dll).
| Dim ieo As SHDocVw.InternetExplorer
| Set ieo = New SHDocVw.InternetExplorer
| ieo.FullScreen = True
| ieo.Navigate sPath
| ieo.Visible = True
| Exit Sub
|
| 'late binding
| Dim IE As Object
| Set IE = CreateObject("internetexplorer.application")
| IE.Navigate sPath
| IE.Visible = True
| Exit Sub
| End Sub
|




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com