Macro which opens folder

lechev65

Board Regular
Joined
Mar 7, 2010
Messages
147
Hi,
I have an excel control sheet for opening different worksheets with click buttons nested in a folder named "DATABASE". Except the excel sheets, I need a macro for opening also the folders inside my folder "DATABASE". I would like to open all the folders inside the "DATABASE" folder without the need of re-addressing when I move the "DATABASE" folder to another computer or drive.
Thank you in advance.
Krasimir
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi Andrewkard,

The code opens the folder "Documents" in the "Users"... I would like to open any folder in my folder "DATABASE" containing excel, pdf, word, etc. files and when I move the "DATABASE" folder to another computer, laptop or drive, the opening function to remain. Thanks in advance!

</PRE>
 
Upvote 0
Hello, something like that:
Code:
Sub test()
Dim oFS As Object, oFl As Object
Dim sFtFd$, sDnFd$
sFtFd = ActiveWorkbook.Path & "\" & "New"
Set oFS = CreateObject("scripting.filesystemobject")
Set oFS = oFS.getfolder(sFtFd)
sDnFd = ActiveWorkbook.Path & "\" & "New2"
MkDir sDnFd
For Each oFl In oFS.Files
oFl.Copy (sDnFd & "\" & oFl.Name)
Next
End Sub
 
Upvote 0
Hi, something wrong, it doesn't work ... where I have to input the file name I want to open with the click button?
 
Upvote 0
Hello, you have to lay your file in a folder which consist a folder named "DATABASE". Than
Code:
Sub test()
Dim oFS As Object, oFl As Object
Dim sFtFd$, sDnFd$sFtFd = ActiveWorkbook.Path & "\" & "DATABASE"
Set oFS = CreateObject("scripting.filesystemobject")
Set oFS = oFS.getfolder(sFtFd)
sDnFd = ActiveWorkbook.Path & "\" & "New" ' New folder
MkDir sDnFd
For Each oFl In oFS.Files
oFl.Copy (sDnFd & "\" & oFl.Name)
Next
End Sub
</PRE>
 
Upvote 0

Forum statistics

Threads
1,203,061
Messages
6,053,307
Members
444,651
Latest member
markkuznetsov1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top