Open a file that is already open

  • Thread starter Thread starter luis
  • Start date Start date
L

luis

Hello.
I'm trying to do 2 things that i explain right away:
1 - I trying to do a VBA function that when you click on a
button, first checks if a certain file is already open,
and if this is true then it doesn't do nothing, and if its
false it opens the file.

2 - How can i open the Start-Run-Browse window with VBA
code?

Thanks
 
Brain dead on the second item, but the first ........

Sub Text()

If Not bIsBookOpen("000 Missing Data.xls") Then _
Workbooks.Open FileName:=Path & "000 Missing Data.xls"

Windows("000 Missing Data.xls").Activate

End Sub

Public Function bIsBookOpen(ByRef szBookName As String) As Boolean
'' Checks to see whether a WorkBook is open.

On Error Resume Next
bIsBookOpen = (Len(Workbooks(szBookName).Name) > 0)

End Function

HTH
Paul
 
This works from a type name in a cell.
Will activate or open if closed.

Sub GetWorkbook()
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows("" & workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
Exit Sub
End Sub
 
Back
Top