Hi all,
I've got a generated link which is placed into a sheet cell of my WB.
I need to also provide access to the file with a link on a userform through
a command button or a generated hyperlink (Label),if that's possible.
I am able to open with the following code using a command button.
However, thus far have not be able to figure out how to bring the openned excel spreadsheet forward / to the front while the userform is open.
Any help is greatly appreciated.
Private Sub CommandButton7_Click()
Dim MAS As Worksheet
Dim Excel As Excel.Application
Dim WB As Workbook
Dim NumBooks As Integer, N As Integer
Dim ThisBook As Integer, FirstBk As Integer
Set MAS = ThisWorkbook.Sheets("MASTER")
Set Excel = New Excel.Application
On Error GoTo 1
Workbooks.Open FileName:=GetAddress(MAS.Cells(4, "E"))
'Application.ScreenUpdating = False
Application.DisplayAlerts = False
NumBooks = Workbooks.Count
If Workbooks(1).Name = ThisWorkbook.Name Then
FirstBk = 2
Else
FirstBk = 1
End If
For N = 1 To NumBooks
If Workbooks(N).Name = ActiveWorkbook.Name Then ThisBook = N
Next
If ThisBook < NumBooks Then
' move to the next books
Workbooks(ThisBook + 1).Activate
End If
If ThisBook = NumBooks And NumBooks > FirstBk Then
' move back to first book
Workbooks(FirstBk).Activate
Else
MsgBox ActiveWorkbook.Name
'ActiveWorkbook.Activate
End If
Exit Sub
1: MsgBox Err.Description
End Sub
Thanks,
BDB
Bookmarks