Thanks Ken
Ken
Thanks for the code unfortunately my knowledge is limited and I can't get it
to work. I have put my code below which I have modified with what you sent,
in the hopes you can assist me further.
I'm not sure if I have all the elements in the correct place or not.
Basically I open OpenPRM.xls which this code is in and that in turn opens
Toolbox.xls, which is hidden. It then opens MasterRoster.xls and then
OpenPRM.xls then closes, leaving MasterRoster.xls in view. In essence all I
want to do is stop this process running again if MasterRoster.xls is already
open.
If I run it as it stands I get a Run-time error 91 at the
"ActiveWindow.Visible = False" line. If I rem it out it loads OK the first
time. If I then open it a second time I get the message "do I want to reopen
or not" If I answer Yes it does If I answer No it gives Run-time error 1004
and stops at the line "Workbooks.Open FileName:=ThisWorkbook.Path &
"\MasterRoster.xls", UpdateLinks:=3".
Is it something to do with where I have put "SummaryFileopen =
WorkBookIsOpen(MasterRoster)"
Private Const SummaryFileName As String = "MasterRoster.xls"
Regards and thanks again
Mick
Function WorkBookIsOpen(MasterRoster) As Boolean
'returns TRUE if the workbook is open
Dim WB As Workbook
On Error Resume Next
Set WB = Workbooks(MasterRoster)
If Err = 0 Then WorkBookIsOpen = True _
Else WorkBookIsOpen = False
End Function
Private Sub CommandButton1_Click()
Workbooks.Open FileName:=ThisWorkbook.Path & "\Toolbox.xls", UpdateLinks:=3,
ReadOnly:=True, ignorereadonlyrecommended:=True
ActiveWindow.Visible = False
SummaryFileopen = WorkBookIsOpen(MasterRoster)
Workbooks.Open FileName:=ThisWorkbook.Path & "\MasterRoster.xls",
UpdateLinks:=3
Workbooks("OpenPRM.xls").Close SaveChanges:=False
End Sub
Regards
Mick