Code : Tout sélectionner
#Include <String.au3>
#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>
#include <Excel.au3>
_Main()
Func _Main()
;variables Locals
;~ $source = @ScriptDir & "\000_Template_Projet" ,
Local $BTNEXIT, $MSG, $BTNOK , $BTNImport,$BTNEnregistrer
Local $file,$NOM,$Prenom,$Service,$folder,$varFile,$varFolder,$version,$TYPE,$redacteur
Local $i=0, $result="",$sFilePath="",$oExcel=""
Local $ligne=16,$CService=2,$CtypeDoc=4,$Cversion=7,$Cindice=8,$Credacteur=9,$Cdate=10,$Ctext=11,$Cnomdoc=13,$sDate = @MDAY & "/" & @MON & "/" & @YEAR
GUICreate("test ", 555, 250, 100, 100) ; will create a dialog box
GUICtrlCreateLabel("céer/modifier un fichier :", 10, 5,120,18)
GUICtrlCreateGroup("fichier ", 10, 25, 260, 190)
GUICtrlCreateLabel("importer fichier : ", 20, 45, 80, 18)
$file = GUICtrlCreateInput("", 100, 45 , 140,18)
$BTNImport = GUICtrlCreateButton("...", 240, 45, 18, 18)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
GUICtrlCreateGroup("Redacteur ", 280, 25, 260, 100)
GUICtrlCreateLabel("NOM : ", 300, 45, 80, 18)
$NOM = GUICtrlCreateInput("toto", 350, 45 , 140,18)
GUICtrlCreateLabel("Prenom : ",300, 70, 50, 18)
$Prenom = GUICtrlCreateInput("tata", 350, 70 , 140,18)
GUICtrlCreateGroup("localisation ", 280, 130, 260, 65)
GUICtrlCreateLabel("enregistrer dans :", 300, 155, 90, 18)
$folder = GUICtrlCreateInput("", 390, 155 , 110,18)
$BTNEnregistrer=GUICtrlCreateButton("...", 500, 155, 18, 18)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
;Buttons
$BTNOK = GUICtrlCreateButton("&OK", 120, 220, 100)
GUICtrlSetTip(-1, "Save")
$BTNEXIT = GUICtrlCreateButton("&Exit", 300, 220, 100)
GUICtrlSetTip(-1, "Quit the program")
GUISetState() ; will display an empty dialog box
While 1
$i=0
$MSG = GUIGetMsg()
Select
Case $MSG = $GUI_EVENT_CLOSE Or $MSG = $BTNEXIT
Exit
Case $MSG = $BTNImport
$var = FileOpenDialog("choisissez le fichier", @ScriptDir & "\", "All (*.*)" , 1 + 2 )
If @error Then
MsgBox(4096,"","No File(s) chosen")
Else
$varFile = StringReplace($var, "|", @CRLF)
MsgBox(4096,"","You chose " & $var)
$file = GUICtrlCreateInput($var, 100, 45 , 140,18)
EndIf
Case $MSG = $BTNEnregistrer
$varFolder=FileSelectFolder("Choose a folder.", @ScriptDir)
$folder = GUICtrlCreateInput($varFolder, 390, 155 , 110,18)
Case $MSG = $BTNOK
If GUICtrlRead($file)="" Then
MsgBox(0,"","Error : vous devez importer un fichier")
$i-=1
ElseIf GUICtrlRead($folder)="" Then
MsgBox(0,"","Error : vous devez choisir un repertoire")
$i-=1
ElseIf GUICtrlRead($NOM)="" or GUICtrlRead($Prenom)="" Then
MsgBox(0,"","Error : vous devez entrer votre nom et votre prenom")
$i-=1
Else
$nom=GUICtrlRead($NOM) & GUICtrlRead($Prenom)
$xlsxFile=GUICtrlRead($folder) & "\" & $nom
EndIf
;coppier et renommer le fichier
If $i=0 Then
Exit
EndIf
EndSelect
WEnd
EndFunc ;==>_Main
Voila mon code. je récupère un fichier et je dois l'enregistrer dans un autre endroit en le renommant.