Hi all,
i have the below code and works fine on my PC
however i need to roll it out across a few PC's and dependant on the person to what Letter the "K" drive is (some people it's been mapped as T etc. as they have access to different drives to me or other people)
if there a way so i can link it to the network drive name?
the network drive is "D_Customer003" on "filgpet03a02"
i think i'd probably have to have it as a seperate declaration but just can't get it to find the filepath can anyone help please!!!
i have the below code and works fine on my PC
however i need to roll it out across a few PC's and dependant on the person to what Letter the "K" drive is (some people it's been mapped as T etc. as they have access to different drives to me or other people)
if there a way so i can link it to the network drive name?
Code:
Option Explicit
Public MyInteger As Integer
Public MyString As String
Public Sub DriveTest()
' Create a variable to hold the free space.
Dim FreeSpace As Double
' Create a reference to the file system.
Dim MyFileSystem As FileSystemObject
' Create a reference for the target drive.
Dim MyDrive As Drive
' Create a dialog result variable.
Dim Result As VbMsgBoxResult
'Provide a jump back point.
DoCheckAgain:
' Fill these two objects with data so they show the
' available space on drive C.
Set MyFileSystem = New FileSystemObject
Set MyDrive = MyFileSystem.GetDrive("K")
' Determine the amount of free space.
FreeSpace = MyDrive.AvailableSpace
' Make the check.
If FreeSpace < 1000000000 Then
' The drive doesn't have enough space. Ask what to
' do.
Result = MsgBox("The drive doesn't have enough " + _
"space to hold the data. Do you" + _
" want to correct the error?" + _
vbCrLf + _
Format(FreeSpace, "###,###") + _
" bytes available, " + _
"1,000,000,000 bytes needed.", _
vbYesNo Or vbExclamation, _
"Drive Space Error")
' Determine if the user wants to correct the error.
If Result = vbYes Then
' Wait for the user to fix the problem.
MsgBox "Please click OK when you have freed" + _
" some disk space.", _
vbInformation Or vbOKOnly, _
"Retry Drive Check"
' Go to the fallback point.
GoTo DoCheckAgain
Else
' The user doesn't want to fix the error.
MsgBox "The program can't save your data " + _
"until the drive has enough space.", _
vbInformation Or vbOKOnly, _
"Insufficient Drive Space"
' End the Sub.
Exit Sub
End If
Else
MsgBox "You've " & Format(FreeSpace, "###,###") + _
" bytes available, greater than the needed 1 GB" & vbCrLf & " Go on....", vbInformation, "Result..."
End If
End Sub
the network drive is "D_Customer003" on "filgpet03a02"
i think i'd probably have to have it as a seperate declaration but just can't get it to find the filepath can anyone help please!!!