HI,
I am trying to insert this code in macro to open a workbook. If already opened, activate it. But for some reason it does not work.
Please help me on this.HTML Code:
Thank you
Jaz
HI,
I am trying to insert this code in macro to open a workbook. If already opened, activate it. But for some reason it does not work.
Please help me on this.HTML Code:
Thank you
Jaz
Last edited by jazbath; 09-17-2009 at 02:08 PM.
A reference to an open workbook doesn't include the path.
![]()
Const sPath As String = "C:\Test\" Const sWkb As String = "mybook.xls" If WorkbookIsOpen(sWkb) Then Workbooks(sWkb).Select Else Workbooks.Open sPath & sWkb End If ... Function WorkbookIsOpen(sWkb As String) As Boolean On Error Resume Next WorkbookIsOpen = Not Workbooks(sWkb) Is Nothing Err.Clear End Function
Entia non sunt multiplicanda sine necessitate
Hi Shg,
Thanks for helping me on this. Where do I ned to put the function?
I inserted in the same workbook as function, it says "Object does not support this porperty or method.
Jaz
Last edited by jazbath; 09-16-2009 at 08:07 PM.
Put the stand-alone function in a code module.
The declarations and code fragment above it replace the code you posted in whatever macro it was in.
Hi Shg,
I did as you mentioned. But still it gives me a run time error 438
in the following line:
Workbooks(sWkb).Select --- Object does not support this property or method.
If the workbook is closed it works well, but if it is open then the above error occurs.
Jaz
Post your code.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks