[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Application.FileSearch runtime error '455' in Excel 2007

Posted on 2008-06-17
5
Medium Priority
?
1,383 Views
Last Modified: 2011-10-19
I have seen some of the other solution here on EE but I don't how to implement them to fit my situation. Here is my code that attempts to look for a file within a specified folder based on county, year, and status. If not found, a message box pops saying "File not found.  Not Created Yet".

I just need to know how to re-arrange the variables I have already set to work with the workaround method for Excel 2007. This file was initially created in Excel 2003.
Sub CheckTargetFile()
   Targetfile1 = "SR_" & cnty & ".txt"
   Dirname1 = "H:\srprod\Data Requests\" & typestudy & "Files\" & year
 
 
   'To make sure that file exists
   With Application.FileSearch
        .NewSearch
        .LookIn = Dirname1
        .Filename = Targetfile1
        If .Execute() = 0 Then
            MsgBox "File not found.  Not Created Yet", vbOKOnly
        Else
            Call Import
        End If
    End With

Open in new window

0
Comment
Question by:angelmtaylor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 19

Expert Comment

by:dlc110161
ID: 21813164
Where do you define what typestudy and year contain? They both look like variables, but I don't see where you have values being passed into them.

Dawn Crosier-Bleuel
Word MVP
0
 

Author Comment

by:angelmtaylor
ID: 21813221
I have attached the code and form that sends the variable values.
Sub Button10_Click()
   If Range("P1").Value = 1 Then
     year = "2000"
   ElseIf Range("P1").Value = 2 Then
     year = "2001"
   ElseIf Range("P1").Value = 3 Then
     year = "2002"
   ElseIf Range("P1").Value = 4 Then
     year = "2003"
   ElseIf Range("P1").Value = 5 Then
     year = "2004"
   ElseIf Range("P1").Value = 6 Then
     year = "2005"
   ElseIf Range("P1").Value = 7 Then
     year = "2006"
   ElseIf Range("P1").Value = 8 Then
     year = "2007"
   End If
 
   If Range("r1").Value < 10 Then
      cnty = "00" & CStr(Range("r1").Value)
   ElseIf Range("r1").Value < 100 Then
      cnty = "0" & CStr(Range("r1").Value)
   Else
      cnty = CStr(Range("r1").Value)
   End If
   
   If Range("T1").Value = 1 Then
     typestudy = "Prelm"
   ElseIf Range("T1").Value = 2 Then
     typestudy = "Study"
   End If
 
   
   Call CheckTargetFile
 
End Sub

Open in new window

form.JPG
0
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 21813904
Hello angelmtaylor,

FileSearch was dropped from Office 2007.  Instead, try:

If Dir(Dirname1 & "\" & Targetfile1) <> "" Then
    'code for file exists
Else
   'does not exist
End If

Regards,

Patrick
0
 

Author Closing Comment

by:angelmtaylor
ID: 31468148
Thank you so much!! It was plug and go with your solution. I don't know why I didn't think if it. You truly are an EXPERT!!  Thanks for your help!!
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 21814784
angelmtaylor,

You are most welcome :)

Regards,

Patrick
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes a serious pitfall that can happen when deleting shapes using VBA.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question