ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening A Folder Using VB Code (https://www.excelbanter.com/excel-programming/286790-opening-folder-using-vbulletin-code.html)

kiza

Opening A Folder Using VB Code
 
Hi,

I need some help with opening a folder by using a macro located within
Excel.

To open a file, it is straight forward as you use the following vb
code:

Workbooks.Open Filename:= _
"C:\Documents and Settings\Administrator\My
Documents\Book1.xls", UpdateLinks _
:=3

However, is it possible to open a folder, say "My Documents" and
secondly, how does one write this in VB code?

Any help would be appreciated.

Many Thanks in advance.

Kiza


---
Message posted from http://www.ExcelForum.com/


Bob Phillips[_6_]

Opening A Folder Using VB Code
 
Kiza,

What do you mean by open a folder? You can easily use the GetOpenFileName
method to navigate through folders and select a file from within a nominated
folder, if this is what you really want. It doesn't open the file, just
returns a full file and path name which you can then pass to the Open method
(see Help).

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"kiza " wrote in message
...
Hi,

I need some help with opening a folder by using a macro located within
Excel.

To open a file, it is straight forward as you use the following vb
code:

Workbooks.Open Filename:= _
"C:\Documents and Settings\Administrator\My
Documents\Book1.xls", UpdateLinks _
:=3

However, is it possible to open a folder, say "My Documents" and
secondly, how does one write this in VB code?

Any help would be appreciated.

Many Thanks in advance.

Kiza


---
Message posted from http://www.ExcelForum.com/




Ron de Bruin

Opening A Folder Using VB Code
 
If you really want to open a folder then use

Sub test()
Shell "explorer.exe C:\Dell", vbNormalFocus
End Sub

But I think you like the GetOpenFileName that Bob posted

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Bob Phillips" wrote in message ...
Kiza,

What do you mean by open a folder? You can easily use the GetOpenFileName
method to navigate through folders and select a file from within a nominated
folder, if this is what you really want. It doesn't open the file, just
returns a full file and path name which you can then pass to the Open method
(see Help).

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"kiza " wrote in message
...
Hi,

I need some help with opening a folder by using a macro located within
Excel.

To open a file, it is straight forward as you use the following vb
code:

Workbooks.Open Filename:= _
"C:\Documents and Settings\Administrator\My
Documents\Book1.xls", UpdateLinks _
:=3

However, is it possible to open a folder, say "My Documents" and
secondly, how does one write this in VB code?

Any help would be appreciated.

Many Thanks in advance.

Kiza


---
Message posted from http://www.ExcelForum.com/







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

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