'outils-Reference Cochez Microsoft Windows Image Acquisition Library
'http://silkyroad.developpez.com/VBA/WindowsImageAcquisition/#LIV-C
'telecharger ce programme pour avoir la dll WIA http://codes-sources.commentcamarche.net/source/48234-boite-couleurs
'tout la marche à suivre est expliqué
Option Explicit
Dim Img As ImageFile
'numérisation
Private Sub CommandButton1_Click()
Dim wiaImg As New WIA.ImageFile
Dim wiaDialog As New WIA.CommonDialog
Dim wiaScanner As WIA.Device
Set Img = wiaDialog.ShowAcquireImage
If Not Img Is Nothing Then
Set Image1.Picture = Img.FileData.Picture
End If
End Sub
'enrgistrement
Private Sub CommandButton2_Click()
Img.SaveFile "C:\Users\Daniel\Documents\Scanner.JPG"
End Sub
Private Sub UserForm_Initialize()
Image1.PictureSizeMode = fmPictureSizeModeZoom
End Sub
'outils-Reference Cochez Microsoft Windows Image Acquisition Library
'http://silkyroad.developpez.com/VBA/WindowsImageAcquisition/#LIV-C
'telecharger ce programme pour avoir la dll WIA http://codes-sources.commentcamarche.net/source/48234-boite-couleurs
'tout la marche à suivre est expliqué
Option Explicit
Dim wiaImg As New WIA.ImageFile
Dim wiaDialog As New WIA.CommonDialog
'numérisation
Private Sub CommandButton1_Click()
Set wiaImg = wiaDialog.ShowAcquireImage
If Not wiaImg Is Nothing Then
Set Image1.Picture = wiaImg.FileData.Picture
End If
End Sub
'enregistrement
Private Sub CommandButton2_Click()
wiaImg.SaveFile "C:\Users\Daniel\Documents\essai.JPG"
End Sub
Private Sub UserForm_Initialize()
Image1.PictureSizeMode = fmPictureSizeModeZoom
End Sub
'numerisation avec aperçu et choix de scanner et d'enregistrement dans options
Private Sub CommandButton3_Click()
Dim MonDevice As Device
Set MonDevice = wiaDialog.ShowSelectDevice
If Not (MonDevice Is Nothing) Then
wiaDialog.ShowAcquisitionWizard MonDevice
End If
End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionShell "wiaacmgr.exe", vbNormalFocus
Private Sub CommandButton1_Click() 'Apui sur Capture Scan
Dim ProgScan 'Création de la variable ProgScan (qui contiendra le répertoire le nom du programe de Scannage et les options)
Dim newHour, newMinute, newSecond, waitTime As Date 'Création des variables de tempo
NomRep = Chemin & "\Scan\" 'Chargement dela variable NomRep
'Chargement dela variable ProgScan avec toutes les obtions qui vont bien
ProgScan = "C:\Program Files\GssEziSoft\CmdTwain\CmdTwain.exe /PAPER=A4 /DPI=200 /JPG25"
'Chargement dela variable NomScan avec Nom Prénom Code et .jpg
NomScan = ComboBox1 & " " & ComboBox2 & " " & TextBox1 & ".jpg"
'Lance le programe de Scannérisation (Commande pour appeler un autre programe depuis exel:Call Shell
Call Shell(ProgScan & " " & Chr(34) & NomRep & NomScan & Chr(34))
'Temporisation pour le temps de création de l'image
newMinute = Minute(Now()) 'Initialisation de newMinute
newSecond = Second(Now()) + 20 'Initialisation de newSecond avec une tempo de x secondes
waitTime = TimeSerial(newHour, newMinute, newSecond) 'Initialisation de waitTime
Application.Wait waitTime 'Pose d'atente de création du Scan
Image1.Picture = LoadPicture(NomRep & NomScan) 'Charge l'image
End Sub 'Fin de Procédure
Chemin = ActiveWorkbook.Path 'Charge le répertoire dans le quel est le programe dans Chemin
Option Explicit
'recherche de fichiers avec les fonctions API (rapide, récursif)
'code à étudier :-)
'code : Randy Birch/RB Smissaert (mpep)
'http://www.mvps.org/vbnet/index.html?code/fileapi/recursivefolders_minimal.htm
Private Const vbDot = 46
Private Const MAX_PATH = 260
Private Const INVALID_HANDLE_VALUE = -1
Private Const vbBackslash = "\"
Private Const ALL_FILES = "*.*"
Private fp As FILE_PARAMS 'holds search parameters
Private List1(1000, 0) As String
Private i As Long
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Private Type FILE_PARAMS
bRecurse As Boolean
bFindOrExclude As Long '1=find matching, 0=exclude matching
nCount As Long
nSearched As Long
sFileNameExt As String
sFileRoot As String
End Type
Private Declare Function FindFirstFile Lib "kernel32" _
Alias "FindFirstFileA" _
(ByVal lpFileName As String, _
lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindNextFile Lib "kernel32" _
Alias "FindNextFileA" _
(ByVal hFindFile As Long, _
lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindClose Lib "kernel32" _
(ByVal hFindFile As Long) As Long
Private Declare Function lstrlen Lib "kernel32" _
Alias "lstrlenW" (ByVal lpString As Long) As Long
Private Declare Function PathMatchSpec Lib "shlwapi" _
Alias "PathMatchSpecW" _
(ByVal pszFileParam As Long, _
ByVal pszSpec As Long) As Long
Sub Start() 'recherche fichier
Dim hFile As Long
Dim WFD As WIN32_FIND_DATA
Dim FolderName As String
Dim filename As String
Dim n As Long
Dim temps, count
Dim scan As String
On Error Resume Next
Sheets("Feuil1").Select 'choix feuille
If [A1] = "" Then
scan = InputBox("Entrez le nom de l'exe du scan" & Chr(10) & " Veuillez patienter ensuite pendant la recherche", "Scanner", "HP Photosmart 5510 series.exe")
temps = Timer ' Timer pour calculer la durée de la recherche
FolderName = "C:\" 'Répertoire
If FolderName = "" Then
Exit Sub
End If
filename = scan 'nom Fichier exe scan
If filename = "" Then
Exit Sub
End If
i = 0
Erase List1
With fp
.sFileRoot = QualifyPath(FolderName) 'start path
.sFileNameExt = filename 'file type(s) of interest
.bRecurse = True 'True = recursive search
.nCount = 0 'results
.nSearched = 0 'results
.bFindOrExclude = 1 '1 = find, 0 = exclude
End With
Call SearchForFiles(fp.sFileRoot)
If i = 0 Then
MsgBox filename & " non trouvé, vérifiez l'orthographe.", , " Conclusion du dossier"
Else
For n = 0 To i - 1
count = i 'On compte les fichiers
With ActiveSheet("Feuil1")
[A1] = List1(n, 0) 'on inscrit le chemin du fichier sur la feuille Excel
Application.StatusBar = "Trouvé " & count & " fichier(s) " & filename & " en " & Timer - temps & " secondes."
End With
Next
MsgBox "Trouvé " & count & " fichier(s) " & filename & " en " & Timer - temps & " secondes.", , " Conclusion du dossier"
End If
End If
End Sub
Private Sub SearchForFiles(sRoot As String)
Dim WFD As WIN32_FIND_DATA
Dim hFile As Long
hFile = FindFirstFile(sRoot & ALL_FILES, WFD)
If hFile <> INVALID_HANDLE_VALUE Then
Do
'if a folder, and recurse specified, call
'method again
If (WFD.dwFileAttributes And vbDirectory) Then
If Asc(WFD.cFileName) <> vbDot Then
If fp.bRecurse Then
SearchForFiles sRoot & TrimNull(WFD.cFileName) & _
vbBackslash
End If
End If
Else
'must be a file and not the open temp file (~$....)
If MatchSpec(WFD.cFileName, fp.sFileNameExt) And Not _
Left$(WFD.cFileName, 2) = "~$" Then
fp.nCount = fp.nCount + 1
List1(i, 0) = sRoot & TrimNull(WFD.cFileName)
i = i + 1
End If
End If
Loop While FindNextFile(hFile, WFD)
End If
Call FindClose(hFile)
End Sub
Private Function QualifyPath(sPath As String) As String
If Right$(sPath, 1) <> vbBackslash Then
QualifyPath = sPath & vbBackslash
Else
QualifyPath = sPath
End If
End Function
Private Function TrimNull(startstr As String) As String
TrimNull = Left$(startstr, lstrlen(StrPtr(startstr)))
End Function
Private Function MatchSpec(sFile As String, sSpec As String) As Boolean
MatchSpec = PathMatchSpec(StrPtr(sFile), StrPtr(sSpec)) = _
fp.bFindOrExclude
End Function
'rechercher exe scanner
Private Sub CommandButton1_Click()
Start
End Sub
'boite de dialogue numérisation scanner
Private Sub CommandButton2_Click()
If [A1] = "" Then Exit Sub
Shell [A1], vbNormalFocus
End Sub
19 déc. 2013 à 16:05
2 button dans l'userForm et un contrôle image
19 déc. 2013 à 16:21
ça va les compliquer un peu cette histoire, ou j'ai mal compris...