Académique Documents
Professionnel Documents
Culture Documents
A hyperlink is a convenient way to allow the user of a workbook to instantly access another place in the workbook, another workbook, or a file associated with another application. A hyperlink can be inserted in a cell or a shape in Excel. Select the cell or shape and selectHyperlinkfrom theInsertmenu, or right click on the cell or shape and selectHyperlinkfrom the pop up menu. You can enter a cell reference in the current workbook, browse to another workbook, a different file, or a web page, even enter an email address and subject line. You can also edit the hyperlink text for a hyperlink in a cell.
When the user selects cell B2, the procedure is activated. The code jumps to the sheet with the name in the cell. If Excel cannot go to that sheet, the code assumes it's because the sheet doesn't exist, and alerts the user.
To link to a particular page in a Word document, simply append a pound sign and the page number after the document path and file name:
C:\My Documents\MyDocument.doc#4
You can also write a macro to jump to a particular slide in a presentation. Since the hyperlink above treats me to the slide show view, I would prefer not to use it. The following procedure gets the presentation full name and slide number from A1:A2 of the active sheet, and brings up PowerPoint with the desired slide active.
Sub GotoSlide() '' Late Binding '' Presentation name and path in cell A1 '' Slide number in cell A2 Dim Dim Dim Dim Dim pApp As Object pPreso As Object pSlide As Object sPreso As String iSlide As Integer ' ' ' ' ' PowerPoint.Application PowerPoint.Presentation PowerPoint.Slide Presentation Fullname Slide Index
sPreso = ActiveSheet.Cells(1, 1).Value iSlide = ActiveSheet.Cells(2, 1).Value '' Get active PowerPoint instance On Error Resume Next Set pApp = GetObject(, "PowerPoint.Application") If Err.Number <> 0 Then '' PowerPoint isn't running, so open it Set pApp = CreateObject("PowerPoint.Application") pApp.Visible = True End If On Error GoTo 0 On Error Resume Next '' get our presentation Set pPreso = pApp.presentations(sPreso) If Err.Number <> 0 Then
'' our presentation isn't open, so open it Set pPreso = pApp.presentations.Open(Filename:=sPreso) End If On Error GoTo 0 '' need to be in PowerPoint normal view pApp.ActiveWindow.ViewType = 9 ' ppViewNormal If pPreso.slides.Count >= iSlide Then '' desired slide exists, so open to it pApp.ActiveWindow.View.GotoSlide Index:=2 End If '' activate PowerPoint to display the slide AppActivate pApp.Caption End Sub