AW: ziellink in der zelle drucken
23.08.2005 23:53:06
Josef
Hallo Mehmet!
Mal geraten!
Die links gehen zu Webseiten und nicht zu Dateien auf deinem PC.
Dann vieleicht so!
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _
szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Const t As String = "Ziel drucken"
Sub Kontextmenü_Erweitern()
Dim Kontext As CommandBarButton
Call Kontext_Löschen
Set Kontext = CommandBars("Cell").Controls.Add(Type:=msoControlButton)
With Kontext
.BeginGroup = True
.Caption = t
.OnAction = "MachEs1"
.FaceId = 4
End With
Set Kontext = Nothing
End Sub
Sub Kontext_Löschen()
On Error Resume Next
CommandBars("Cell").Reset
End Sub
Sub MachEs1()
Dim strURL As String
Dim strFile As String
strFile = "C:\Windows\Temp\dummy.html"
If ActiveCell.Hyperlinks.Count > 0 Then
strURL = ActiveCell.Hyperlinks(1).Address
URLDownloadToFile 0, strURL, strFile, 0, 0
ShellExecute 0, "Print", strFile, "", "", 0
Kill strFile
Else
MsgBox "Kein gültiger Hyperlink!", 48, "Hinweis"
End If
End Sub
Gruß Sepp