Bonjour,
j'ai deux gros traitements qui se font:
*voir le code à la fin*- importation des données
- mise en forme du document
le soucis c'est que je ne sais pas quand le pc a terminé ces tâche...

aujourd'hui il y a des tempos un peut folles mais l'aléa fait que ça plante
Code :
1 2 3 4
| 'Timer
Start = Timer
Do While Timer < Start + 10 'il y en a même une de 240sec XD
Loop ' pas de DoEvents pour redonner la main au PC... |
Existe-t-il des boucle qui me parementerais de gérer avec certitude que les deux tâches sont terminées?
code de la première tâche:
Code :
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
| ' recuperation données fichier CSV
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & Chemin, Destination:=Range("A1"))
.Name = "AZERTY_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierNone
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = ";"
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With |
Temps d'attente avant la deuxiéme tache
Code :
1 2 3 4
| 'Timer
Start = Timer
Do While Timer < Start + 10
Loop |
code de la deuxième tâche:
Code :
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
| 'Mise en forme du document
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = "Nom du Header"
.CenterHeader = Sheets("Intouch").Range("A1").Value
.RightHeader = "F0:(en min)" & Sheets("Intouch").Range("A2").Value
.LeftFooter = ""
.CenterFooter = "&P/&N"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.196850393700787)
.RightMargin = Application.InchesToPoints(0.196850393700787)
.TopMargin = Application.InchesToPoints(0.226850393700787)
.BottomMargin = Application.InchesToPoints(0.226850393700787)
.HeaderMargin = Application.InchesToPoints(0.171811023622047)
.FooterMargin = Application.InchesToPoints(0.171811023622047)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 2
.PrintErrors = xlPrintErrorsDisplayed
End With |
temps d'attente pour passer à la suite
Code :
1 2 3 4
| 'Timer
Start = Timer
Do While Timer < Start + 10
Loop |
Si vous pensez que le code des tâches est à refaire,
*n'hésitez pas à me le dire*
personnellement je ne comprend pas tout et mon ami

ne m'aide pas beaucoup...
pour la conversion PDF, j'ai des boucles qui me permettent de gérer tout ça
Code :
1 2 3
| Do Until JobPDF.cCountOfPrintjobs = 1
DoEvents
Loop |
existe-t-il la même chose pour ce qui est fait précédemment?