49413

trouble referencing Windows Portable Device files in VBA?

Question:

I have been tirelessly searching for a solution to my problem but have not found anything helpful!! So I hope someone on here can help my specific situation... Thanks in advance!

So, I have a barcode scanner that stores inventory in its internal memory as a text file. Through the use of Windows Mobile Device Center 6.1 I am able to, on my PC, navigate through the scanners folders and open up that text file to see what items I scanned.

I am writing an excel macro that will open up that text file, read each line of inventory, and then do other things with it. I have been successful thus far if I copy that text file on the scanner into some places like 'My Documents'. However, I want to make it easy and be able to open up that text file directly from the scanner.

My problem is with referencing the path to the scanner. Because it is a portable device, it does not have a drive like C: or something. Instead the path looks like 'Computer\MT2070-ML416147\Application\Inventory\export.txt'. However when I try to open that path for input I get an error saying "Path not found".

If anyone can assist I would be very appreciative!! If anyone requires code snippets of what I have, please let me know.

Answer1:

There is no way to access the contents of attached Windows CE device's filesystem through the Windows filesystem API, this is because they are not mounted volumes. Your device appears in Windows Explorer because WMDC installs a Shell Namespace handler that creates shell folders that represent the attached device - this is the same way that the Control Panel and Network Places folders work, even though they too are not true filesystem directories. Think of it as Windows hand-waving over the filesystem abstraction.

All is not lost, however, you have a few options:

<ol><li>Use the Smart Device Connectivity API to explore the device and get data files out of it: <a href="https://msdn.microsoft.com/en-us/library/bb384093.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/bb384093.aspx</a> - this is the same API that Explorer is using when it shows you shell folders of the device.</li> <li>Remove the storage volume (e.g. an SD card) from the device and plug it in to an SD card reader on your computer so you can browse and manipulate the filesystem directly.</li> <li>Write a program that runs on the device itself to push data from the device to a shared location.</li> </ol>

Option 1 will get you the best results but will likely require coding against it in C++/Win32. VBA is not the best environment to do systems programming in. You can always write in C++ and expose your layer as a COM object which you can then consume through VBA. Though you'll run into problems with 32/64-bitness of Office, and probably sandboxing issues too.

Option 3 will be slightly difficult as the last SDK for the "Windows Mobile" flavour of Windows CE was released for Visual Studio 2008 - there is no support for more recent versions of VS. That means using either the anemic Compact Framework 3.5 or C++03 against the WinCE API. Coincidentally, I believe this is part of the reason Windows Mobile was doomed when the iPhone came out: the environment was just too neglected and behind it couldn't keep up.

Answer2:

Check if your device is accessible via Shell.Application ActiveX. Below is the example that shows all items in "Printers and Faxes" location:

Sub Test() Set objShellApp = CreateObject("Shell.Application") Set objFolder = objShellApp.Namespace("::{2227a280-3aea-1069-a2de-08002b30309d}") ' Printers and Faxes Debug.Print "CLSID:" & vbCrLf & objFolder.Self.Path & vbCrLf Debug.Print "Folder name: " & vbCrLf & objFolder.Self.Name & vbCrLf For Each objItem In objFolder.Items() Debug.Print objItem.Name Next End Sub

The output for me is as follows:

<blockquote>

CLSID:<br /> ::{2227A280-3AEA-1069-A2DE-08002B30309D} Folder name: <br /> Printers Fax<br /> Microsoft XPS Document Writer<br /> PDFCreator<br /> Send To OneNote 2013<br /> ...-P0086 on ...-s0002<br /> ...-P0087 on ...-s0002<br /> ...-P0049 on ...-S0002<br /> ...-P0068 on ...-S0002<br /> ...-P0067 on ...-S0002<br />

</blockquote>

Try another CLSIDs, like:

<pre class="lang-none prettyprint-override">::{20D04FE0-3AEA-1069-A2D8-08002B30309D} - Computer ::{00f2886f-cd64-4fc9-8ec5-30ef6cdbe8c3} - Scanners and Cameras ::{fb0c9c8a-6c50-11d1-9f1d-0000f8757fcd} - Scanners and Cameras ::{e211b736-43fd-11d1-9efb-0000f8757fcd} - Scanners and Cameras ::{0c15d503-d017-47ce-9016-7b3f978721cc} - Portable Device Values ::{35786d3c-b075-49b9-88dd-029876e11c01} - Portable Devices

Take a look eg <a href="https://stackoverflow.com/questions/37171394/how-to-create-shortcut-to-computer-on-the-users-desktop" rel="nofollow">here</a>, <a href="https://autohotkey.com/docs/misc/CLSID-List.htm" rel="nofollow">here</a> and <a href="https://github.com/williballenthin/shellbags/blob/master/known_guids.py" rel="nofollow">here</a>. If you find the device name in one of the displayed items, then you will apparently be able to retrieve the file from it.

Recommend

  • How can I call Workbook_Open on Workbook A from Workbook B?
  • SSRS Count IF Multiple values
  • How to return only text after a comma in a string
  • OpenSubKey under HKLM\\Software returning null
  • ButterKnife findByID method is deprecated in version 8.8.0
  • Do I need to clean up the char* passed to NewStringUTF?
  • All I get is a blank page when I visit localhost:9080
  • Nodejs + Mongo db connect with server database with username and password
  • In Android P: Dropping event due to no window focus: KeyEvent
  • Bind a function to multiple dynamically created buttons in kivy?
  • Unable to edit with bcdedit filelds in powershell - cmd.exe command line fails
  • Delphi MainFormOnTaskBar Modal windows bug
  • VC++ 6.0 access violation when run in debugger
  • Backing up data volume containers off machine
  • Excel VBA: Forward ParamArray to Application.Run
  • Why context.Wait in StartAsync didn't stop the dialog
  • Python PIL cut words out so it becomes transparent PNG
  • PostgreSQL in Docker - pg_hba.conf to allow access from host to container
  • How to build executable with pyinstaller that uses pycryptodome?
  • Identify xml text elements with Schematron
  • Salesforce consuming XML and display data in Visualforce report
  • how to change the black color to Red with opencv python
  • Can I switch the 'connected' user within an sql script that is sourced by mysql?
  • How to delete first 7 characters of folder name by using batch script?
  • Was there ever a proposal to include the URL fragment into the HTTP request?
  • Create .java file and compile it to a .class file at runtime
  • Unsupported ciphersuite TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
  • Find all parks for a given zipcode with google maps
  • Javascript inside HTML import not affecting imported HTML
  • Swift manually rotate view controller
  • readmore button or show/hide for php
  • Silverlight Event Log in Isolated Storage
  • time column in sqlite using gorm
  • Creating 2d platforms using JavaScript
  • How to write seo friendly url's using htaccess?
  • PHPMailer return to AJAX
  • Is there a better way for handling SpatialPolygons that cross the antimeridian (date line)?
  • Can a PHP script be scheduled to run at a specific time or after a specific amount of time has expir
  • How to call jQuery function in HTML returned by AJAX
  • How to check if object is null in Java?