Macro to open and close an Excel file
Try this...
Sub OpenClose()
Dim wbk As Workbook
On Error Resume Next
Set wbk = Workbooks.Open(Sheets("Sheet1").Range("A1"))
On Error GoTo 0
If wbk Is Nothing Then Exit Sub
MsgBox wbk.Name & " is open."
wbk.Close
MsgBox "And now it is closed."
Set wbk = Nothing
End Sub
--
HTH...
Jim Thomlinson
"Magnivy" wrote:
I would like to create a macro that would open an Excel file based on file
path that is indicated in a cell, and then close it. For instance, open the
file for which the file path is indicated in cell A1, and then close it.
Any advice you could provide on this would be greatly appreciated.
Magnivy
|