+ Reply to Thread
Results 1 to 6 of 6

Excel 2000 VBA can I use Mkdir with variables?

  1. #1
    Forum Contributor
    Join Date
    06-11-2018
    Location
    Lebanon, NH
    MS-Off Ver
    2000 and 2010
    Posts
    106

    Excel 2000 VBA can I use Mkdir with variables?

    Good afternoon!
    I am working on a way to create a new folder named the same as the file that will reside there. I've looked lots of stuff up on MKDIR but haven't found a definitive answer.
    My file contains only the info in D10 as this is a new project. The location for the new folder should be S:\Estimates & Prelim\current 4 digit year\new folder
    D10 contains the following: 040919-bill-363

    This is the very simple macro I put together to try to make this work
    Please Login or Register  to view this content.
    I obviously don't understand all that I know about this. I would be very appreciative of any suggestions or even a simple "You can't use variables in a MKDIR argument"
    Thanks very much,
    Bill
    Last edited by billfinnjr; 04-12-2019 at 02:31 PM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Excel 2000 VBA can I use Mkdir with variables?

    The MkDir line should be
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    06-11-2018
    Location
    Lebanon, NH
    MS-Off Ver
    2000 and 2010
    Posts
    106

    Re: Excel 2000 VBA can I use Mkdir with variables?

    Fluff,
    Thanks for the response!!
    The directory represented by cyear already exists, I am trying to create a sub folder within that folder. I had hopped to make this so it didn't need to be modified every January.
    What I need is to always create a new sub folder in the one named for the current year and then save my file there
    Thanks much!
    Bill

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Excel 2000 VBA can I use Mkdir with variables?

    In that case you need to give Filename a value before trying to create the new folder.
    I would also recommend against using VBA keywords (such as Path & Filename) for names of variables.

  5. #5
    Forum Contributor
    Join Date
    06-11-2018
    Location
    Lebanon, NH
    MS-Off Ver
    2000 and 2010
    Posts
    106

    Re: Excel 2000 VBA can I use Mkdir with variables?

    Fluff,
    Once again you have led me into the light! I was just trying to prove out the technique but I changed all the variables to be unique names and rearranged the commands. It now works as I had wanted it to.
    Current state of the macro is as follows;
    [CODE]
    [Sub New_Folder()

    Dim cyear As Integer

    Dim cpath As String

    Dim cfile As String

    cyear = Year(Now())
    cfile = Range("D10")

    MkDir "S:\Estimates & Prelim\" & cyear & "\" & cfile 'This should create the new folder

    cpath = "S:\Estimates & Prelim\" & cyear & "\" & cfile & "\" 'this adds the newly created path to the save as argument



    ActiveWorkbook.SaveAs filename:=cpath & cfile & ".xls"

    End Sub/CODE]
    Thanks again for your help,
    Bill

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Excel 2000 VBA can I use Mkdir with variables?

    You're welcome & thanks for the feedback

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. mkdir - Create folders from Excel list
    By swmasson in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-13-2016, 05:23 PM
  2. Excel VB MkDir and File Save
    By sdrane in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-25-2009, 03:58 AM
  3. Replies: 1
    Last Post: 07-22-2006, 01:33 PM
  4. [SOLVED] I cannot edit cell format in Excel 2000 (Part of office 2000)!
    By Brett in forum Excel General
    Replies: 1
    Last Post: 04-12-2006, 01:10 PM
  5. Replies: 0
    Last Post: 09-27-2005, 09:05 AM
  6. Using Excel 2000 as Data source for Word 2000 document
    By Malcolm Agingwell in forum Excel General
    Replies: 2
    Last Post: 06-21-2005, 05:05 AM
  7. [SOLVED] mkdir command in excel 2003 on XP SP2
    By zvi carmi via OfficeKB.com in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-25-2005, 08:06 AM
  8. [SOLVED] Hyperlink in Excel 2000 can't open bookmarked Word 2000 file
    By DCheslock in forum Excel General
    Replies: 1
    Last Post: 05-05-2005, 06:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1