Make new directory using open workbook

Drfox3

New Member
Joined
Mar 15, 2011
Messages
7
Anyone know how to create a new directory using the open workbook as the last folder in the directory?
For example;
I am in directory c:\testa\testb\testc
My workbook is named Nova.xlsc

I would like to make a new directory (while executing VBA) that would be c:\testa\testb\testc\Nova\.
Any idea how to do that?
I have been working on this for days.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try...

Code:
[font=Verdana]    [color=darkblue]Dim[/color] strFile [color=darkblue]As[/color] [color=darkblue]String[/color]
    [color=darkblue]Dim[/color] strDir [color=darkblue]As[/color] [color=darkblue]String[/color]

    strFile = ActiveWorkbook.Name

    strDir = Left(strFile, InStr(1, strFile, ".xls", vbTextCompare) - 1)
    
    MkDir ActiveWorkbook.Path & "\" & strDir
    [/font]

Note, however, if you mean Nova.xlsx and not Nova.xlsc, you can replace...

Code:
strDir = Left(strFile, InStr(1, strFile, ".xls", vbTextCompare) - 1)

with

Code:
strDir = Left(strFile, InStr(1, strFile, [COLOR="Red"]".xlsx"[/COLOR], vbTextCompare) - 1)
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,520
Members
452,921
Latest member
BBQKING

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