Lester
11-08-2007, 09:32 AM
Hello again
Does anyone know how I should 'close' an open workbook?
I have tried the following code but there is a syntax error in my attempt at the 'close' command'.
I can comment out the offending line and the code runs OK, but it leaves the workbook open.
Many thanks
Lester
Sub ImportLookUp()
Dim oWB As Workbook
Dim oThis As Workbook
Set oThis = ActiveWorkbook
Set oWB = Workbooks.Open("G:\temp\ChargeRatesLookUp.xls")
oWB.Sheets("Charge Rates Look-up").Copy after:=oThis.Worksheets(oThis.Worksheets.Count)
'New line added below - but there's a syntax error
Set oWB = Workbooks.Close("G:\temp\ChargeRatesLookUp.xls")
End Sub
Does anyone know how I should 'close' an open workbook?
I have tried the following code but there is a syntax error in my attempt at the 'close' command'.
I can comment out the offending line and the code runs OK, but it leaves the workbook open.
Many thanks
Lester
Sub ImportLookUp()
Dim oWB As Workbook
Dim oThis As Workbook
Set oThis = ActiveWorkbook
Set oWB = Workbooks.Open("G:\temp\ChargeRatesLookUp.xls")
oWB.Sheets("Charge Rates Look-up").Copy after:=oThis.Worksheets(oThis.Worksheets.Count)
'New line added below - but there's a syntax error
Set oWB = Workbooks.Close("G:\temp\ChargeRatesLookUp.xls")
End Sub