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
| Option Explicit
Sub RecupTableau()
'--- reprend les données dans Power Query --- adresse du fichier à adapter
ActiveWorkbook.Queries.Add Name:="TABLEAU COMPLET", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Csv.Document(File.Contents(""D:\! Tests\TABLEAU COMPLET.txt""),[Delimiter="";"", Columns=29, Encoding=65001, QuoteStyle=QuoteStyle.Csv])," & Chr(13) & "" & Chr(10) & " #""En-têtes promus"" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])," & Chr(13) & "" & Chr(10) & " #""Type modifié"" = Table.TransformColumnTypes(#""En-têtes promus"",{{""Titre formation"", type text}, {""Code formation""," & _
" Int64.Type}, {""Session"", Int64.Type}, {""Partie"", type text}, {""Date début partie"", type date}, {""Date fin partie"", type date}, {""Nom formateur"", type text}, {""Prénom formateur"", type text}, {""Identifiant formateur"", Int64.Type}, {""Nom Stagiaire"", type text}, {""Prénom stagiaire"", type text}, {""Identifiant stagiaire"", Int64.Type}, {""Établissement" & _
" stagiaire"", type text}, {""Qui a choisi la formation ?"", type text}, {""Le contenu de la formation était-il en conforme au programme initial ?"", type text}, {""Cette formation a t-elle répondu à vos attentes ?"", type text}, {""Les thématiques abordées sont-elles adaptées à votre environnement professionnel ?"", type text}, {""Le formateur maîtrisait-il son dom" & _
"aine d'intervention ?"", Int64.Type}, {""A-t'il été à l'écoute de vos attentes pendant et après la formation ?"", Int64.Type}, {""A-t'il su favoriser les échanges au sein du groupe ?"", Int64.Type}, {""Le formateur a-t'il illustré la partie théorique avec des applications pratiques ?"", Int64.Type}, {""Les outils utilisés pendant la formation étaient-ils pertinents " & _
"?"", Int64.Type}, {""La documentation remise vous semble t'elle contenir les points essentiels de la formation ?"", Int64.Type}, {""Etes-vous en mesure de mettre en pratique les acquis de la formation ?"", type text}, {""Avez-vous atteint les objectifs de la formation ?"", type text}, {""La formation suivie contribue t'elle à améliorer vos compétences ?"", type tex" & _
"t}, {""De manière générale, comment évaluez-vous la formation suivie ?"", Int64.Type}, {""Recommanderiez-vous cet organisme de formation à d'autres personnes ?"", Int64.Type}, {""Afin de nous aider à améliorer nos prestations et à vous proposer des formations de qualité, avez-vous des remarques et/ou suggestions ?"", type text}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Type modifié"""
'--- inscrit les données de Power Query dans une nouvelle feuille
ActiveWorkbook.Worksheets.Add
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=""TABLEAU COMPLET"";Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [TABLEAU COMPLET]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "TABLEAU_COMPLET"
.Refresh BackgroundQuery:=False
End With
'--- supprime la connexion Power Query
ActiveWorkbook.Queries("TABLEAU COMPLET").Delete
'--- quelques formatages
Cells.VerticalAlignment = xlCenter
Cells.WrapText = True
Columns("A:M").ColumnWidth = 10
Columns("N:N").ColumnWidth = 30
Columns("O:AB").ColumnWidth = 24
Columns("AC:AC").ColumnWidth = 60
Rows("1:1").VerticalAlignment = xlCenter
End Sub |
Partager