MS отключил доступ к камерам в Windows 10. Устройства больше не рассматриваются как устройства WIA или устройства хранения данных, а как устройства WPD (переносные устройства Windows). Как результат, существующие решения терпят неудачу
FileDialog больше не работает, так как переход к устройству WPD выглядит нормально, но возвращает только «Этот компьютер» при .Show. WIA.DeviceManager больше не будет обнаруживать какие-либо устройства камеры, поэтому WIA.CommonDialog не может быть направлен на камеры.
Спасибо MS за то, что он разоблачил это без особой причины
Итак, что может вызывать VBA иполучить данные, которые позволят пользователю выбрать несколько фотографий из папки DCIM камеры, а затем извлечь выбранные элементы для копирования в файл системы?
'This is now broken as WIA no longer detects cameras as WIA devices
Dim DM As Object
Set DM = CreateObject("WIA.DeviceManager")
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
'variables for a recordet in tblPictures
'fix the set = rs(...) to match what your needs may be
Dim db As Database
Dim rs As Recordset
Set db = CurrentDbC
Set rs = db.OpenRecordset("SELECT * FROM [tblPictures] WHERE Jobid =" & Me.Parent!JobID.value & ";", dbOpenDynaset, dbSeeChanges)
'JobID is my main lookup tables primary key
'I use it in relating the pictures to what job they belong to
'It is something that you will need to alter in the context of your own needs
myJobID = Me.JobID
For i = 1 To DM.DeviceInfos.Count 'run through the devices in a loop
Set dev = DM.DeviceInfos(i).Connect ' connect to it
Select Case True
Case (dev.Type = 2 And dev.Properties("Name").value Like "canon*") 'its a canon camera 'CameraDeviceType
devName = dev.Properties("Name").value
Exit For
Case (dev.Type = 2 And dev.Properties("Name").value Like "HP*") 'CameraDeviceType
devName = dev.Properties("Name").value
Exit For
Case (dev.Type = 2 And dev.Properties("Name").value Like "Apple*") 'CameraDeviceType
devName = dev.Properties("Name").value
Exit For
Case (dev.Type = 2 And dev.Properties("Name").value Like "A10*") 'CameraDeviceType
devName = dev.Properties("Name").value
Exit For
Case Else
MsgBox dev.Type & dev.Properties("Name").value
End Select
Next
If Not ((devName Like "HP*") Or (devName Like "canon*") Or (devName Like "Apple*") Or (devName Like "A10*")) Then
Exit Function 'an eligible camera was not detected
End If
'(...more code to do stuff)
'This is now broken as FileDialog does not return useful values from WPD devices, but only 'This PC'
'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(3) 'msoFileDialogFilePicker
'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
.AllowMultiSelect = True
.InitialView = 5 'msoFileDialogViewThumbnail
.title = "Picture Selector"
'.InitialFileName = MyInitialFileName '"E:\DCIM"
.InitialFileName = MyInitialFileName 'FDInitialFilename()
.ButtonName = "Xfer and Save"
'Use the Show method to display the File Picker dialog box and return the user's action.
'The user pressed the action button.
If .Show = True Then
'(...code to run through when FileDialog gets .Show )
Мне нужно диалоговое окно, которое позволитмножественный выбор файлов с устройства WPD без буквы диска, чтобы вернуть значения в VBA и разрешить копирование выбранных файлов в файловую систему. Учитывая, что и FileDialog, и WIA теперь разбиты MS, что еще может служить этой цели?