WAS? - nur 1/2Std. LOL
WARUM? - eigentlich Workbook.FollowHyperlink
Das Application.Object nimmt den Standard-Viewer von Windows und der ist womöglich nicht so prickelnd.
Dennoch habe ich es einmal bei Fotoanzeige belassen, jedoch
ShellExecute Function verwendet (bei lpOperation kann jedes Ausführbare eingetragen werden).
CODE läuft z.Zt. Windows 7/64bit und Excel 2013/32bit, ggf. sind Anpassung der Deklarationen nötig.
CODE = Quick&Dirty, d.h. kann/aber muss nicht Version.
Option Explicit
'
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'
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
'
Public Declare Function GetDesktopWindow Lib "user32" () As Long
'
Public Declare Function GetWindowRect Lib "user32" ( _
ByVal hWnd As Long, lpRect As RECT) As Long
'
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
'
Public Declare Function MoveWindow Lib "user32" ( _
ByVal hWnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal bRepaint As Long) As Long
'
Public Declare Function BringWindowToTop Lib "user32" (ByVal hWnd As Long) As Long
'
Sub byShell()
Dim i As Integer
Dim strLink As String
Dim strWndName As String
'Hyperlinks (Daten) in A1-A4, egal wir nehmen Daten
'Standard Open für Bilddateien Windows-Fotoanzeige
For i = 1 To 4
strLink = Cells(i, 1).Value 'Dateipfad
strWndName = WndName(strLink) 'Fenstername der akt. Fotoanzeige
Auto_Open strLink, strWndName, i
Next i
End Sub
Private Sub Auto_Open(imgPath As String, imgWnd As String, cnt As Integer)
Dim cmdPath As String
Dim hWnd As Long
Dim arrQ() As Long
arrQ = QuarterIt(cnt)
hWnd = ShellExecute(0, "", imgPath, "", "", 0)
Sleep 100
hWnd = FindWindow(vbEmpty, imgWnd)
Sleep 100
'ggf.
'BringWindowToTop hWnd
Call MoveWindow(hWnd, arrQ(0), arrQ(1), arrQ(2), arrQ(3), 1)
Sleep 100
End Sub
Function QuarterIt(nQ As Integer) As Variant
Dim R As RECT
Dim arrPos(0 To 3) As Long
If GetWindowRect(GetDesktopWindow, R) = 0 Then Exit Function
'Fensteraufteilung Version 0.0 mit Lüftungsschlitzen
Select Case nQ
Case 1
arrPos(0) = 0
arrPos(1) = 0
arrPos(2) = R.Right / 2 - 2
arrPos(3) = R.Bottom / 2 - 2
Case 2
arrPos(0) = 0
arrPos(1) = R.Bottom / 2 + 1
arrPos(2) = R.Right / 2 - 2
arrPos(3) = R.Bottom / 2 - 2
Case 3
arrPos(0) = R.Right / 2 + 1
arrPos(1) = 0
arrPos(2) = R.Right / 2 - 2
arrPos(3) = R.Bottom / 2 - 2
Case 4
arrPos(0) = R.Right / 2 + 1
arrPos(1) = R.Bottom / 2 + 1
arrPos(2) = R.Right / 2 - 2
arrPos(3) = R.Bottom / 2 - 2
End Select
QuarterIt = arrPos
End Function
Private Function WndName(LinkPath) As String
Dim strNm As String
strNm = Split(LinkPath, "\")(UBound(Split(LinkPath, "\")))
strNm = strNm & " - Windows-Fotoanzeige"
WndName = strNm
End Function
|