DIR() throwing run time error 52

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sunny009
    New Member
    • Feb 2016
    • 1

    DIR() throwing run time error 52

    Hi,

    I am running a code to automate a report. Part of that automation is to go to share point site open up a file based on wild card section and follow on with the code.

    I am using DIR() to return the exact file name based on wild card combinations.

    It works fine most of the time but at some specific triggers it runs into run time error 52 right at the line where DIR() is being called.

    I have to manually run that DIR() by removing the wildcard combination and actually relacing it with the exact file name to get it working again or else it would not move.

    Need help with making it more stable or consistent. Can FSO solve my problem here and how?

    Mentioning the code which runs into the error:

    Code:
    Public Cmbval As String
    Public actwbk As String
    
    Public Sub Report()
    
        Dim myPath As String
        Dim myFile As String
        Dim fnName As String
        Dim filend1 As String
        Dim filend2 As String
        
    'Choose file name and path based on the combobox selection by the user in a form displayed as the workbook opens
        
    Select Case Cmbval
       Case Is = "Dec-15"
       myPath = ("\\wbcspaces@SSL\my\teams\")
       myFile = Dir("\\wbcspaces@SSL\my\teams\Rptnm2015-12-*.csv*")
              
       If (myFile = "") Then
       MsgBox "No file found"
       UserForm1.Show
       Exit Sub
       Else
       'Do something
       End If
       End Select
    Any help/advise is appreciated
    Last edited by Rabbit; Feb 19 '16, 05:38 AM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
Working...