Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Is there a floppy disk in Drive A?

My VBA code includes a DIR statement to check if a specified file is present
on the floppy disc in drive A, and will copies it to the C: drive if it is
present. But this test fails when there is no disc in the drive. Is there
a simple condition which will detect that Drive A: is ready, with a disc
present?

' COPY MAIN SOURCE FILES FROM FLOPPY DISK IF PRESENT

If Dir("A:\Main000.txt") < "" Then FileCopy "A:\Main000.txt", WL5 &
"Main000.txt"
DirEntry = Dir("A:\Main" & "???.txt")
Do While DirEntry < ""
SourceFileName = Mid(DirEntry, 5, 3)
If SourceFileName < "000" Then
Open WL5 & "MainS" & SourceFileName & ".txt" For Output As #1
Open "A:\Main" & SourceFileName & ".txt" For Input As #2
I = 0
Do While Not EOF(2)
I = I + 1
Line Input #2, TextLine
Print #1, TextLine
Loop
Close #2


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Is there a floppy disk in Drive A?

Adding to John's great solution, for this spesific task something more primitive should
also work:

Function Flop() As Boolean
On Error Resume Next
If IsError(Dir("A:\Main*.txt")) Then
Flop = False
Else
Flop = Len((Dir("A:\Main*.txt")))
End If
End Function

Sub test()
If Flop = False Then
MsgBox "No flop"
Else
MsgBox "We found " & Dir("A:\Main*.txt")
End If
End Sub

--
HTH. Best wishes Harald
Excel MVP

Followup to newsgroup only please.

"Hotbird" wrote in message
...
My VBA code includes a DIR statement to check if a specified file is present
on the floppy disc in drive A, and will copies it to the C: drive if it is
present. But this test fails when there is no disc in the drive. Is there
a simple condition which will detect that Drive A: is ready, with a disc
present?

' COPY MAIN SOURCE FILES FROM FLOPPY DISK IF PRESENT

If Dir("A:\Main000.txt") < "" Then FileCopy "A:\Main000.txt", WL5 &
"Main000.txt"
DirEntry = Dir("A:\Main" & "???.txt")
Do While DirEntry < ""
SourceFileName = Mid(DirEntry, 5, 3)
If SourceFileName < "000" Then
Open WL5 & "MainS" & SourceFileName & ".txt" For Output As #1
Open "A:\Main" & SourceFileName & ".txt" For Input As #2
I = 0
Do While Not EOF(2)
I = I + 1
Line Input #2, TextLine
Print #1, TextLine
Loop
Close #2




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i add additional info to a floppy disk? Wouldlikttoknow. Excel Discussion (Misc queries) 8 January 13th 08 04:53 PM
Copying files from floppy to disk ljwag New Users to Excel 2 September 14th 07 05:34 AM
CAN YOU SAVE EXCEL DOCUMENT TO FLOPPY DISK ellie Excel Discussion (Misc queries) 2 May 17th 07 02:30 AM
How to save to my floppy disk? Doreen New Users to Excel 2 December 14th 06 11:45 PM
Saving onto Floppy Disk woodbunny Excel Worksheet Functions 1 August 17th 05 03:43 PM


All times are GMT +1. The time now is 07:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"