+ Reply to Thread
Results 1 to 8 of 8

MkDir VBA Help want to use a ../filename structure

Hybrid View

stevedeer MkDir VBA Help want to use a... 04-04-2016, 10:26 AM
Norie Re: MkDir VBA Help want to... 04-04-2016, 10:27 AM
stevedeer Re: MkDir VBA Help want to... 04-04-2016, 10:33 AM
Norie Re: MkDir VBA Help want to... 04-04-2016, 10:47 AM
stevedeer Re: MkDir VBA Help want to... 04-04-2016, 10:54 AM
Norie Re: MkDir VBA Help want to... 04-04-2016, 11:00 AM
stevedeer Re: MkDir VBA Help want to... 04-04-2016, 11:20 AM
stevedeer Re: MkDir VBA Help want to... 04-04-2016, 11:51 AM
  1. #1
    Registered User
    Join Date
    03-19-2015
    Location
    Austin, Texas
    MS-Off Ver
    2013
    Posts
    21

    Question MkDir VBA Help want to use a ../filename structure

    When I was working in the workbook and initially input
    MkDir "..\Submittal Packaged\BOM PDF"
    the script executed without any issues and created the folder.

    After saving the workbook and re-oppening it gives the folling Run time error 76: Path not found.

    Nothing had changed since executed originally.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: MkDir VBA Help want to use a ../filename structure

    Is the active directory the same as it was when you first ran the code?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    03-19-2015
    Location
    Austin, Texas
    MS-Off Ver
    2013
    Posts
    21

    Re: MkDir VBA Help want to use a ../filename structure

    yes it is. Has not changed

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: MkDir VBA Help want to use a ../filename structure

    What do you get when you enter this in the Immediate Window?
    ? CurDir

  5. #5
    Registered User
    Join Date
    03-19-2015
    Location
    Austin, Texas
    MS-Off Ver
    2013
    Posts
    21

    Re: MkDir VBA Help want to use a ../filename structure

    Not sure I understand are you asking me to put the CurDir command into the VBA window?

    Here is my whole code to help also.... thing is also I am on a network server that we have defined as the Y drive.

    Public Sub CopyFile2()
        MkDir ("..\Submittal packaged\BOM PDF")
        Dim rng As Range
        Const strNewDir As String = "..\Submittal Packaged\BOM PDF\"
        
        For Each rng In Range("L9:L1042").SpecialCells(xlCellTypeVisible)
            If CBool(rng.Hyperlinks.Count) Then
                With rng.Hyperlinks(rng.Hyperlinks.Count)
                    If CBool(InStr(.Address, Chr(92))) Then
                        If Dir(strNewDir & Replace(.Address, Chr(92), vbNullString, InStrRev(.Address, Chr(92)))) = "" Then
                            FileCopy .Address, _
                            strNewDir & Replace(.Address, Chr(92), vbNullString, InStrRev(.Address, Chr(92)))
                        Else
                            FileCopy .Address, _
                            strNewDir & rng.Row & "-" & Replace(.Address, Chr(92), vbNullString, InStrRev(.Address, Chr(92)))
                        End If
                    Else
                        If Dir(strNewDir & .Address) = "" Then
                            FileCopy .Address, _
                            strNewDir & .Address
                        Else
                            FileCopy .Address, _
                            strNewDir & rng.Row & "-" & .Address
                        End If
                    End If
                End With
            End If
        Next rng
    End Sub

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: MkDir VBA Help want to use a ../filename structure

    Open the Immediate Window (CTRL+G) and enter this.
    ?CurDir
    What is the result?

    Is it a path to a folder that contains a directory named 'Submittal Packaged'?

  7. #7
    Registered User
    Join Date
    03-19-2015
    Location
    Austin, Texas
    MS-Off Ver
    2013
    Posts
    21

    Re: MkDir VBA Help want to use a ../filename structure

    C:\Users\steve\Documents

    Which I do not understand since I am running and executing from the networked drive.

  8. #8
    Registered User
    Join Date
    03-19-2015
    Location
    Austin, Texas
    MS-Off Ver
    2013
    Posts
    21

    Re: MkDir VBA Help want to use a ../filename structure

    ChDrive "y:"
    ChDir ThisWorkbook.Path
    Was able to fix with

+ 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. BUG! VBA MKDIR folders cannot be deleted
    By TryToUnderstandExcel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2017, 09:14 AM
  2. Creating a Pyramid Hierarchy structure from a flat structure
    By thegamerulez in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-16-2014, 01:28 AM
  3. [SOLVED] VBA: MkDir Compile Error??
    By sanjeevpandey in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-29-2013, 03:42 PM
  4. [SOLVED] Find if filename exists and update variable within the filename structure
    By Lungfish in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 03-18-2013, 02:42 AM
  5. MkDir with cell value as folder name.
    By tdo4h in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 08-24-2012, 06:37 AM
  6. MkDir not working
    By pprseller in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-23-2009, 12:47 PM
  7. MKDir not working
    By Robert_L_Ross in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2006, 02:20 AM

Tags for this Thread

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