1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| 'CREATION DES OBJETS
Set object_exec_cmd = CreateObject("WScript.Shell")
Set objet_connect_lecteur = CreateObject("WScript.Network")
Set objet_copie = CreateObject("Scripting.FileSystemObject")
'CONNEXION DU LECTEUR RESEAU
function Connexion()
ligne_cmd = "net use W: \\frer0645\out"
Call object_exec_cmd.Run (ligne_cmd)
end function
function fnGetMyPathVB()
BIF_browseIncludeFiles = &H4000
BIF_noFolderButton = &H200
BIF_editbox = &H0010
dim oFolder
dim objFolderItem
Dim objPath
set oShell = CreateObject("Shell.Application")
Set oFolder = oShell.BrowseForFolder(0, "Select a file or folder", BIF_browseIncludeFiles,"frer0645\out")
'Je tente de recupérer le path du fichier mais ça bloque avant, à BrowseForFolder
if (not oFolder is nothing) then
ShowOpenFolder="C:"
Set objFolderItem = oFolder.Self
objPath = objFolderItem.Path
ShowOpenFolder = objPath
end if
set oFolder = nothing
set oShell = nothing
Verif()
end function
'VERIFICATION LECTEUR RESEAU CONNECTE AVANT COPIE
function Verif()
do while objet_copie.DriveExists("W:") = false
loop
Copie() 'La copie peut s'effectuer une fois le lecteur connecté
end function
'COPIE DU FICHIER
function Copie()
objet_copie.CopyFile "objPath","C:\\"
end function
'PROCEDURE PRINCIPALE
Sub DownloadFile()
Connexion() 'Si le lecteur existe, reconnexion.
Verif()
fnGetMyPathVB()
end Sub |
Partager