Is the floppy in the A drive?

  • Thread starter Thread starter jim simpson
  • Start date Start date
J

jim simpson

I would like to determine if the floppy in the "A" drive and if it is post a
msgbox saying so. I have not been able to do this and haven't seen any
messages on the subject.

Can someone please help me?.
Thanks

Jim
 
try this

Function FloppyInDrive()
Dim sTemp

On Error GoTo haveError
sTemp = Dir("A:\")
FloppyInDrive = True
Exit Function

haveError:
FloppyInDrive = False
End Function

Tim.
 
Another option:

Option Explicit
Sub testme03()

'Dim FSO As Scripting.FileSystemObject
Dim FSO As Object

'Set FSO = New Scripting.FileSystemObject
Set FSO = CreateObject("scripting.filesystemobject")

With Application
If FSO.Drives("a").IsReady Then
MsgBox "ok"
Else
MsgBox "not ready"
End If
End With
End Sub


If you uncommment the top lines of each pair (and comment the bottom), you'll
have to set a reference (tools|references) to Microsoft Scripting Runtime.

When you have that reference set, you'll get the VBE's intellisense to help you
complete your code.
 
Thanks to both Tim and Dave for responding.

Dave sometning doesn't work with the top lines of each pair commented out. I
get a complaint about "ScriptingFileSystemObject". It says "User defined
type not defined". I'm using Excel 2000 with Win98, could that be the
problem?

Jim
 
jim simpson said:
Thanks to both Tim and Dave for responding.

Dave sometning doesn't work with the top lines of each pair commented out.
I
get a complaint about "ScriptingFileSystemObject". It says "User defined
type not defined". I'm using Excel 2000 with Win98, could that be the
problem?

Jim
If you want to use early binding which is more efficient you need to go to
Tools | References in the VBA editor and check the box next to Microsoft
Scripoting Runtime, or use the browse button to find scrrun.dll in your
system directory. Then you use:

Dim FSO As Scripting.FileSystemObject
Set FSO = New Scripting.FileSystemObject

This also gives you intellisense support. If setting a refence is going to
be awkward then you can use late binding with:

Dim FSO As Object
Set FSO = CreateObject("scripting.filesystemobject")
 
Jim,

Both Dave's methods worked for me in Win98 / XL2000

If you uncomment the first pair you need to comment the second pair AND set
a reference to Microsoft Scripting Runtime, the way Dave described.

Regards,
Peter


jim simpson said:
Thanks to both Tim and Dave for responding.

Dave sometning doesn't work with the top lines of each pair commented out. I
get a complaint about "ScriptingFileSystemObject". It says "User defined
type not defined". I'm using Excel 2000 with Win98, could that be the
problem?

Jim
 
Thanks Guys, for all hte great help.

Clicking on the "Microsoft Scripoting Runtime" box did the trick. Now I have
2 solutions to my problem.

Jim

Peter T said:
Jim,

Both Dave's methods worked for me in Win98 / XL2000

If you uncomment the first pair you need to comment the second pair AND set
a reference to Microsoft Scripting Runtime, the way Dave described.

Regards,
Peter


jim simpson said:
Thanks to both Tim and Dave for responding.

Dave sometning doesn't work with the top lines of each pair commented
out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top