userform Image mit LoadPicture Bild wird nicht geladen
29.11.2023 00:03:27
Jochen
Hier die Datei : https://www.herber.de/bbs/user/164642.xlsm
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
Public Function qrcode(QRCode_Wert As String) As String
'Variablen deklarieren
Dim sURL As String, strTemp As String
Dim result As Long
'URL definieren
sURL = "https://chart.googleapis.com/chart?cht=qr&&chs=100x100&&chl=" & QRCode_Wert
'Alten QR-Code löschen, falls vorhanden
On Error Resume Next
XTicket.ImQr.Picture = LoadPicture("")
On Error GoTo 0
'QR-Code einfügen
If sURL = "" Then Exit Function
strTemp = Environ("TEMP") & "\tmp." & "bmp"
result = URLDownloadToFile(0, sURL, strTemp, 0, 0)
' Bild auswählen und Pfad und Bildname in tag schreiben
' UserForm aktualisieren damit Bild angezeigt wird (kann einen Augenblick dauern)
If result = 0 Then
On Error Resume Next
'Prüfen, ob Datei vorhanden
XTicket.ImQr.Picture = LoadPicture(strTemp)
XTicket.ImQr.PictureSizeMode = fmPictureSizeModeStretch
If Err Then
MsgBox "Ungeeigneter Dateityp!", 64, "Fehler"
Err.Clear
End If
On Error GoTo 0
Kill strTemp
Else
MsgBox "Internetfile nicht gefunden!", 64, "Fehler"
End If
qrcode = "erledigt"
End Function