I have VB codes to generate a few pivot tables in Excel. My company has just switched from Excel 2003 to 2007.
[login to view URL] function does not work in 2007. I need someone to fix the VB codes. The enclosed example shows where the problem is. Thank you.
Function reportFileExist() As Boolean
Dim FS As [login to view URL]
Dim DR As String
Dim path As String
Dim vaFilename As Variant
Dim icount As Long
Dim icount2 As Long
Dim stMessage As String
Dim maindir As String
maindir = ":\Analysis\BDO-VA"
DR = [login to view URL]("Page1").TbDrive
path = DR + maindir + [login to view URL] + "" + [login to view URL]
Set FS = [login to view URL]
' for report option = 1
If [login to view URL] Then
With FS
.NewSearch
.LookIn = path
.filename = "[login to view URL]"
'MsgBox .filename
icount2 = .Execute
stMessage = Format(icount2, "0 ""Files Found""")
'MsgBox stMessage
End With
With FS
.NewSearch
.LookIn = path
.filename = "[login to view URL]"
'MsgBox .filename
icount = .Execute
stMessage = Format(icount, "0 ""Files Found""")
'MsgBox stMessage
End With
If icount > 0 And icount2 > 0 Then
reportFileExist = True
Else:
reportFileExist = False
End If
End If
' if the option is not report 1
If Not [login to view URL] Then
With FS
.NewSearch
.LookIn = path
.filename = "[login to view URL]"
'MsgBox .filename
icount = .Execute
stMessage = Format(icount, "0 ""Files Found""")
'MsgBox stMessage
End With
If icount > 0 Then
reportFileExist = True
Else: reportFileExist = False
End If
End If
End Function
VBA developer since 1997. It's kinda Microsoft sent us all back in time, right? (Somewhere in the last millennium). Good news is this fix is not such a big problem. The old good Dir will do the trick. Can do. Regards, Svet.