Sub ScanToExcel()

Dim wiaDia As Object Dim wiaImg As Object Dim imgPath As String Dim imgFile As String Dim imgWidth As Integer Dim imgHeight As Integer Dim imgTop As Integer Dim imgLeft As Integer

'Create WIA Dialog Set wiaDia = CreateObject("WIA.CommonDialog")

'Scan Image Set wiaImg = wiaDia.ShowAcquireImage()

'Check if image was scanned If Not wiaImg Is Nothing Then

'Save image to temp folder
imgPath = Environ("temp") & "\scan.jpg"
wiaImg.SaveFile (imgPath)

'Insert image into Excel
With ActiveSheet.Pictures.Insert(imgPath)

    'Get image size and position
    imgWidth = .Width
    imgHeight = .Height
    imgTop = .Top
    imgLeft = .Left
    
    'Resize and reposition image
    .Width = 200
    .Height = 200
    .Top = 50
    .Left = 50
    
End With

'Delete temp image file
Kill imgPath

End If

End Su

使用VBA语言编写一个调用已安装扫描仪扫描图片并将扫描的图片插入EXCEL

原文地址: http://www.cveoy.top/t/topic/foF6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录