scan multiple pages using vba into word .docx

39 views Asked by At

Hi i was looking at other threads similar to this but they all seem to be for PDFs. I have a macro that i need to run which calls up the scanner and scans docs into word365. I found a working vba code online but it only allows for 1 page to be scanned even if multiples are in the ADF. here is the code im currently using:

Sub Scan()
    'Requires a reference to Microsoft Windows Image Acquisition Object Library
     Dim objCommonDialog As WIA.CommonDialog
     Dim objImage As WIA.ImageFile
     Dim strPath As String

    On Error Resume Next
    Set objCommonDialog = New WIA.CommonDialog
    Set objImage = objCommonDialog.ShowAcquireImage
    strPath = Environ("TEMP") & "\TempScan.jpg" ' set temporary file

    If Not objImage Is Nothing Then
    objImage.SaveFile strPath ' save into temporary file
    ' Insert in Word Document
    Selection.InlineShapes.AddPicture strPath

    '+++++++++++++++++++++++++++++++++++++
    ' Insertion alternatives


    ' Insert in Excel worksheet
    'ActiveSheet.Pictures.Insert(strPath).Select

    'Insert into Outlook message
    ' If ActiveInspector.IsWordMail And ActiveInspector.EditorType = olEditorWord Then
    ' ActiveInspector.WordEditor.Application.Selection.InlineShapes.AddPicture strPath
    ' End If
    'End If
    '+++++++++++++++++++++++++++++++++++++
    Set objImage = Nothing
    End If
    If Not Dir(strPath) = vbNullString Then Kill strPath 'Remove the temporary file
    Set objCommonDialog = Nothing
    End Sub

I dont know what needs modified to have it prompt or even just automatically scan every page into the word365 doc. any help would be greatly appreciated.

i have only tried this, i googled it for word 365 and couldnt find any good results. the old simple code we used to use in office 2010 worked flawlessly but now in word365 it wont.

0

There are 0 answers