This code snippet worked fine in 7 but fails after upgrade to 10. I get "runtime error '5': Invalid call or argument" on fname = Dir:
Any idea why?
I have a similar problem with another code (in that it worked in 7 but not in 10). This time I get "Compile error: Can't find project or library" on "Dim FileSys As FileSystemObject". Nothing's changed...only the upgrade (well, new computer that has Windows 10):
Code:
oldpath = "\\DSGAIN01\Commercial_Printing\Work Flow\WEEKLY PRESS-DIST REPORTS - COMM\02 JACKSONVILLE\" & BUNIT & "\"
newpath = "\\DSGAIN01\Commercial_Printing\Work Flow\WEEKLY PRESS-DIST REPORTS - COMM\02 JACKSONVILLE\" & BUNIT & "\OUTSIDE DATE PARAM\"
fname = Dir(oldpath & AWN)
fnamea = oldpath & AWN
fnameb = newpath & AWN
If Len(Dir$(fnameb)) > 0 Then
Kill (fnamea)
GoTo SKIP
End If
Do While fname <> ""
Name oldpath & fname As newpath & fname
fname = Dir
Loop
Any idea why?
I have a similar problem with another code (in that it worked in 7 but not in 10). This time I get "Compile error: Can't find project or library" on "Dim FileSys As FileSystemObject". Nothing's changed...only the upgrade (well, new computer that has Windows 10):
Code:
Sub PLANTER()
Dim FileSys As FileSystemObject
Dim objFile As File
Dim myFolder
Dim strFilename, YEER As String
Dim strFilename2 As String
Dim dteFile As Date
Dim FN As String
YEER = Right(Range("A46"), 2)
Const myDir As String = "\\DSGAIN01\Commercial_Printing\OSB Distribution\Leesburg Commercial Totals\Apopka " '"c:\Refresh"
Set FileSys = New FileSystemObject
Set myFolder = FileSys.GetFolder(myDir & YEER)
dteFile = DateSerial(1900, 1, 1)
For Each objFile In myFolder.Files
If objFile.DateLastModified > dteFile Then
dteFile = objFile.DateLastModified
strFilename = objFile.PATH
strFilename2 = objFile.Name
End If
Next objFile
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Workbooks.Open strFilename
Dim WB As Workbook, WN As String, INS As Integer
INS = ActiveWorkbook.Worksheets("Crew Sheet").Range("O29").Value
For Each WB In Application.Workbooks
If WB.Name Like "*PLANTER*" Then
WB.Activate
End If
Next WB
ActiveSheet.Range("D46") = INS
Worksheets("BILLING FORM (NEW)").Shapes("TextBox 20").TextFrame.Characters.Text = strFilename2
For Each WB In Application.Workbooks
If WB.Name Like "PLanter*" Then
WB.Close savechanges:=False
End If
Next WB
Set FileSys = Nothing
Set myFolder = Nothing
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
End Sub
Last edited: