Use VBA To Eject USB pen

james_halliwell

Registered User.
Local time
Today, 23:19
Joined
Feb 13, 2009
Messages
211
Hi,

hoping someone can help me out, I am using a usb pen to import data to my database, I use the below code to make sure the correct pen is inserted as I have mapped it to Z:, what I would like is it eject the pen once its completed, trying to stop people just pulling out the pen!!!!


this code checks to make sure the pen is in and its mapped to the Z: drive (Only way I could think as the drives change)

Dim MyDrive$, MyDriveDir$
'Checks to make sure the correct usb is inserted "Z Drive"
MyDrive = "Z"
On Error Resume Next
MyDriveDir = Dir(MyDrive & ":\", 5)
If MyDriveDir = "" Or IsError(MyDriveDir) Then
MsgBox "Please insert the USB pen assigned to this tablet, Which will show as Drive " & MyDrive

any advice would be perfect
 
You might have a look at this link. It's a bit dated but you may still find it helpful. If you want to read the full thread that the post in the above link originated from, look here.
 
Hi an thanks for the link, tried it in windows 7 and it doesn't work, tired calling it from a module bit I get a sub or function not defind error?


Private Sub Image125_Click()
Call Eject(Z)
End Sub
 

Users who are viewing this thread

Back
Top Bottom