Results 1 to 5 of 5
  1. #1
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150

    Dir command failing with Type mismatch Error

    Hey all,

    I'm hoping someone can help.

    I'm trying to do something very simple.

    Code:
    If Len(Dir(WoPath, vbDirectory)) = 0 Then MkDir (WoPath)
    But it's failing with Runtime error 13 - Type Mismatch and I have no idea why. There are spaces in the string so I've also tried the following with the same error:

    Code:
    If Len(Dir(""" & WoPath & """, vbDirectory)) = 0 Then MkDir (WoPath)
    Code:
    If Len(Dir("'" & WoPath & "'", vbDirectory)) = 0 Then MkDir (WoPath)
    The string eventuates to "\\<SERVER NAME>\Biomass_Main$\17. AIT\01 IPS-ACS documents and Photos\01_IPS Plans\01_SM\12877654_PXMZPY EQUIPMENT PANEL THERMAL EQUIP…" which is 147 characters long and the directory does not exist yet.

    If anyone has any ideas it would really be appreciated. I've already tried a compact and repair as well.



    Cheers
    Robyn

  2. #2
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    To add. It fails on the Dir command. If you just execute that separately you still get the error

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,788
    Sometimes it isn't the code you show (where it balks) - it's what comes before it. Try substituting a valid existing path or perhaps examine the contents of your variable before the Dir function line is processed; assuming you did declare it as a string variable to start with.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    DIR went out back when windows was born....try:

    if not DirExists(wopath) then MkDir wopath


    Code:
    Public Function DirExists(ByVal pvDir) As Boolean
    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    DirExists = fso.FolderExists(pvDir)
    Set fso = Nothing
    End Function

    or even:

    Code:
    Public Sub MakeDir(ByVal pvDir)
    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FolderExists(pvDir) Then fso.CreateFolder pvDir     'MkDir pvDir
    Set fso = Nothing
    End Sub
    





  5. #5
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Great, that worked perfectly. Thank-you

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Type 13 (Type Mismatch) error
    By sdel_nevo in forum Programming
    Replies: 5
    Last Post: 01-22-2016, 10:01 AM
  2. error 13 type mismatch
    By jkd in forum Programming
    Replies: 2
    Last Post: 04-19-2014, 09:46 PM
  3. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  4. Replies: 1
    Last Post: 05-11-2012, 10:59 AM
  5. Error#13 Type Mismatch
    By Nistin27 in forum Access
    Replies: 8
    Last Post: 08-17-2011, 04:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums