How do you use "If" statement to open a workbook, and if closed to open it?
Give an example please...
Thanks alot,
Mike
Try this
Dim oWb As Workbook
On Error Resume Next
Set oWb = Workbooks("SIP 2004.xls")
On Error GoTo 0
If oWb Is Nothing Then
Workbooks.Open Filename:="SIP 2004.xls"
End If
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Michael" <mas_i...@yahoo.com> wrote in message
news:118f1485.04021...@posting.google.com...
Sub Function WB_Open(filename as string)
Dim WBook As Workbook
On Error Resume Next
Set WBook = Workbooks(filename)
On Error GoTo 0
If WBook Is Nothing Then
Workbooks.Open Filename:= filename
End If
end Sub
--
Regards
Frank Kabel
Frankfurt, Germany
--
Regards
Frank Kabel
Frankfurt, Germany
Frank Kabel wrote:
> Hi
> try the following UDF
>
> Sub Function WB_Open(filename as string)
> Dim WBook As Workbook
> On Error Resume Next
> Set WBook = Workbooks(filename)
> On Error GoTo 0
> If WBook Is Nothing Then
> Workbooks.Open Filename:= filename
> End If
> end Sub
>
>
>
Mike
"Frank Kabel" <frank...@freenet.de> wrote in message news:<eRQwfl$8DHA...@TK2MSFTNGP10.phx.gbl>...