I am basically making a template that multiple people will use. I need the macro to open a workbook, and then later close the workbook it opened after running a few steps. The opened workbook may not always have the same name. I would really like to get away with not using specific workbook names at all, not even for the active workbook. The code is below and I have put in bold the parts I'm haivng issue with.
Code:
Sub PullInResults()
Application.ScreenUpdating = False
Application.Calculation = xlManual
Sheet2.Select
Cells.Select
Selection.ClearContents
Range("A1").Select
[B]DAWRKBK = ThisWorkbook.Name
Set DstWks1 = ThisWorkbook.Worksheets("Query Results")[/B]
[B]NewFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.csv), *.csv", Title:="Please select the query results file you just saved")
If NewFN = False Then
'They pressed Cancel
MsgBox "Stopping because you did not select a file"
Exit Sub
Else
Workbooks.Open Filename:=NewFN
[/B]End If
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks(DAWRKBK).Activate
Sheet2.Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
[B]Windows("FCO Query Results.csv").Close
Windows("FCO_Summary.xlsm").Activate[/B]
Sheet3.Select
End Sub