File Not Found Error on String File reference

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Neuman
    New Member
    • Feb 2008
    • 1

    File Not Found Error on String File reference

    I have the following code:
    Code:
    Dim fname As Integer
    fname = cboPlanYearBPTCreation.Value
    
    Dim BPTExcelFile As String
    BPTExcelFile = "C:\Program Files\PBP" & fname & "\CY" & fname & "MA BPT.xls"
    Dim BPTExcelXLA As String
    BPTExcelXLA = "C:\Program Files\bpt" & fname & "\BPT" & fname & ".xla"
    
    Dim App As Excel.Application
    Dim Wkbk As Excel.Workbook
    
    On Error GoTo ErrorHandler
    If I dim the Excel filenames as constants and hard-code in the fname (which is just 2008 or 2008), the erro handler works, but if I use the above code with the fnames embedded in the strings, the errorhandler is ignored. Can I create a dynamic path based on the value of a combo box and call an error handler if the path doesn't exist?

    Thanks,
    Neuman
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Hello, Neuman.

    Are you sure that the error occurs after "On Error" statement has been executed?

    Regards,
    Fish

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #3
      What do you mean by "the error handler works" and "call an error handler"?
      I'm having difficulty understanding what you mean when you describe what's going wrong.

      Comment

      Working...