Соскоб изображения в доступе - PullRequest
0 голосов
/ 31 января 2019

Я сгенерировал матрицу данных с помощью Access vba.Теперь я должен втирать эту сгенерированную картинку в мою форму каждый раз.Вот кодПоловина части генерирует штрих-код, а половина, чтобы очистить эту картинку в форме доступа не работает.

Private Sub Command24_Click()

Dim IE As New InternetExplorer

IE.Visible = True

IE.Navigate ("https://barcode.tec-it.com/en/DataMatrix?data=" & Forms!QRcodes!Text)
Do
DoEvents
Loop Until IE.ReadyState = READYSTATE_COMPLETE
StatusBar = "loading webpage...."

Dim img As Object
Dim html As HTMLDocument
Set html = IE.Document
Dim elementcol As Object, link As Object
Set elementcol = html.getElementsByTagName("img")

Dim doc As Object

Forms!QRcodes!OLEBound34 = elementcol

'Set img = ele.getElementsByTagName("img")
Set Tables!QRcodes!Matrix = elementcol

MsgBox "Getting Code"

End Sub

1 Ответ

0 голосов
/ 31 января 2019

Получите скелет для полного URL только к сгенерированной картинке (как показано на сайте) - например:

https://barcode.tec-it.com/barcode.ashx?data=12345678&code=DataMatrix&multiplebarcodes=false&translate-esc=false&unit=Fit&dpi=96&imagetype=Gif&rotation=0&color=%23000000&bgcolor=%23ffffff&qunit=Mm&quiet=0&dmsize=Default' alt='Barcode Generator TEC-IT

Затем вы можете использовать мой код и опубликованную демонстрациюв одной из моих статей:

Показывать картинки прямо из URL-адресов в формах и отчетах Access

Две основные функции загружают картинки напрямую, одна кеширует загрузку:

' Download a file or a page with public access from the web as a cached file of Internet Explorer.
' Returns the full path of the cached file if success, an empty string if not.
'
' Examples:
'
' Download a file:
'   Url = "https://www.codeproject.com/script/Membership/ProfileImages/%7Ba82bcf77-ba9f-4ec3-bbb3-1d9ce15cae23%7D.jpg"
'   Result = DownloadCacheFile(Url)
'   Result -> C:\Users\UserName\AppData\Local\Microsoft\Windows\INetCache\IE\B2IHEJQZ\{a82bcf77-ba9f-4ec3-bbb3-1d9ce15cae23}[2].png
'
' Download a page:
'   Url = "https://www.codeproject.com/Tips/1022704/Rounding-Values-Up-Down-By-Or-To-Significant-Figur?display=Print"
'   Result = DownloadCacheFile(Url)
'   Result -> C:\Users\UserName\AppData\Local\Microsoft\Windows\INetCache\IE\B2IHEJQZ\Rounding-Values-Up-Down-By-Or-To-Significant-Figur[1].htm
'
' 2017-05-25. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function DownloadCacheFile( _
    ByVal Url As String) _
    As String

    Const BufferLength  As Long = 1024
    Const BindFDefault  As Long = 0
    Const ErrorNone     As Long = 0

    Dim FileName        As String
    Dim LocalFileName   As String
    Dim Result          As Long

    ' Create buffer for name of downloaded and/or cached file.
    FileName = Space(BufferLength - 1) & vbNullChar
    ' Download file or page.
    ' Return name of cached file in parameter FileName.
    Result = URLDownloadToCacheFile(0, Url & vbNullChar, FileName, BufferLength, BindFDefault, 0)

    ' Trim file name.
    LocalFileName = Split(FileName, vbNullChar)(0)

    DownloadCacheFile = LocalFileName

End Function

Я протестировал несколько URL-адресов, и коды были отображены сразу:

enter image description here

...