Hello,
I have a macro built to open a "source" workbook, copy and paste a range into a "master" workbook.
The "source" file has the .xls extension, but when you open it you get the warning that its in a different format.
Below is my code - its works fine if I have recently opened the "source" file - but when I exit excel and try to rerun the macro - I get a run time error saying it couldn't find a file with that name. Any thoughts on how I can fix my code to identify the file with .xls extension but that is in different format?
"Sub PropertiesTB()Application.DisplayAlerts = False
Dim PropTB As Workbook
Set PropTB = ThisWorkbook
Dim TBMonth
TBMonth = InputBox("Type Month and Year", "Month and Year", "MM/YY")
Dim MonthFolder
MonthFolder = InputBox("Current Month Folder", "Month")
Const FilePath = "Z:\2016 Financial Statements\"
Dim Source As String
Source = Dir(FilePath & MonthFolder & "\MMC\Property Financials\" & TBMonth & " Trial Balance.xls")
Do While Source <> vbNullString
Workbooks.Open FileName:=Source
Exit Do
Loop
Range("F7").Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlDown)).Copy
PropTB.Activate
Sheets("Landmark TB").Select
Range("A7").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("1015 Trial Balance.xls").Activate
ActiveWindow.Close savechanges:=False
Application.DisplayAlerts = True
End Sub"
I have a macro built to open a "source" workbook, copy and paste a range into a "master" workbook.
The "source" file has the .xls extension, but when you open it you get the warning that its in a different format.
Below is my code - its works fine if I have recently opened the "source" file - but when I exit excel and try to rerun the macro - I get a run time error saying it couldn't find a file with that name. Any thoughts on how I can fix my code to identify the file with .xls extension but that is in different format?
"Sub PropertiesTB()Application.DisplayAlerts = False
Dim PropTB As Workbook
Set PropTB = ThisWorkbook
Dim TBMonth
TBMonth = InputBox("Type Month and Year", "Month and Year", "MM/YY")
Dim MonthFolder
MonthFolder = InputBox("Current Month Folder", "Month")
Const FilePath = "Z:\2016 Financial Statements\"
Dim Source As String
Source = Dir(FilePath & MonthFolder & "\MMC\Property Financials\" & TBMonth & " Trial Balance.xls")
Do While Source <> vbNullString
Workbooks.Open FileName:=Source
Exit Do
Loop
Range("F7").Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlDown)).Copy
PropTB.Activate
Sheets("Landmark TB").Select
Range("A7").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("1015 Trial Balance.xls").Activate
ActiveWindow.Close savechanges:=False
Application.DisplayAlerts = True
End Sub"