3

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.

ariel
  • 31
  • 2

2 Answers2

4

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:

  1. Use the Smart Device Connectivity API to explore the device and get data files out of it: https://msdn.microsoft.com/en-us/library/bb384093.aspx - this is the same API that Explorer is using when it shows you shell folders of the device.
  2. 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.
  3. Write a program that runs on the device itself to push data from the device to a shared location.

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.

Dai
  • 141,631
  • 28
  • 261
  • 374
  • I thought you had a GREAT Answer; especially option 1. Just wanted to comment, though, that I think VBA IS a great environment for doing systems programming. Having been an assembly, C, C++ programmer all my life (50+ years) I've found VBA much more practical for all my systems programming that doesn't require speed. So far, i haven't found anything I can do in Assembly or C/C++ that I can't do in VBA. – SixSigmaGuy Feb 13 '23 at 04:15
1

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:

CLSID:
::{2227A280-3AEA-1069-A2DE-08002B30309D}

Folder name:
Printers

Fax
Microsoft XPS Document Writer
PDFCreator
Send To OneNote 2013
...-P0086 on ...-s0002
...-P0087 on ...-s0002
...-P0049 on ...-S0002
...-P0068 on ...-S0002
...-P0067 on ...-S0002

Try another CLSIDs, like:

::{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 here, here and here. If you find the device name in one of the displayed items, then you will apparently be able to retrieve the file from it.

omegastripes
  • 12,351
  • 4
  • 45
  • 96
  • You can't believe how much your sample code helped me!! Thank you!! Can't believe it's over 6 years old and it's still helpful – SixSigmaGuy Feb 13 '23 at 04:22