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
| 'Ouvre le document word
Dim oWord As New Word.Application
oWord.Documents.Open(My.Application.Info.DirectoryPath & "\Rapports\Rapport Test.docx")
oWord.Visible = True
Dim oDoc As Word.Document
oDoc = oWord.ActiveDocument
oDoc.Bookmarks.Item("GraphAnalyseTendance").Range.Select()
Dim oChart As Word.Chart
oChart = oDoc.Shapes.AddChart(Microsoft.Office.Core.XlChartType.xlLine).Chart
Dim chartdata As Word.ChartData = oChart.ChartData
Dim dataWorkbook As Excel.Workbook = CType(chartdata.Workbook, Workbook)
Dim datasheet As Excel.Worksheet = CType(dataWorkbook.Worksheets(1), Worksheet)
Dim tRange As Excel.Range = datasheet.Cells.Range("A1", "G" & Nb_Mesures_Optifive)
Dim tbl1 As Excel.ListObject = datasheet.ListObjects("Tableau1")
tbl1.Resize(tRange)
datasheet.Cells.Range("B1").FormulaR1C1 = "Axe XCF"
datasheet.Cells.Range("C1").FormulaR1C1 = "Axe YCF"
datasheet.Cells.Range("D1").FormulaR1C1 = "Axe ZCF"
datasheet.Cells.Range("E1").FormulaR1C1 = "Axe XAC"
datasheet.Cells.Range("F1").FormulaR1C1 = "Axe YAC"
datasheet.Cells.Range("G1").FormulaR1C1 = "Axe ZAC"
For i = 4 To Nb_Mesures_Optifive + 3
datasheet.Cells.Range("A" & i - 2).FormulaR1C1 = i - 3
datasheet.Cells.Range("B" & i - 2).FormulaR1C1 = Math.Round(Val(Data_Optifive_Seconde(i, 0)), 3, MidpointRounding.AwayFromZero) 'XCF
datasheet.Cells.Range("C" & i - 2).FormulaR1C1 = Math.Round(Val(Data_Optifive_Seconde(i, 1)), 3, MidpointRounding.AwayFromZero) 'YCF
datasheet.Cells.Range("D" & i - 2).FormulaR1C1 = Math.Round(Val(Data_Optifive_Seconde(i, 2)), 3, MidpointRounding.AwayFromZero) 'ZCF
datasheet.Cells.Range("E" & i - 2).FormulaR1C1 = Math.Round(Val(Data_Optifive_Premiere(i, 0)), 3, MidpointRounding.AwayFromZero) 'XAC
datasheet.Cells.Range("F" & i - 2).FormulaR1C1 = Math.Round(Val(Data_Optifive_Premiere(i, 1)), 3, MidpointRounding.AwayFromZero) 'YAC
datasheet.Cells.Range("G" & i - 2).FormulaR1C1 = Math.Round(Val(Data_Optifive_Premiere(i, 2)), 3, MidpointRounding.AwayFromZero) 'ZAC
Next
oChart.SetElement(Microsoft.Office.Core.MsoChartElementType.msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
oChart.SetElement(Microsoft.Office.Core.MsoChartElementType.msoElementPrimaryValueAxisTitleRotated)
Dim AxisY As Word.Axis = CType(oChart.Axes(Word.XlAxisType.xlValue, Word.XlAxisGroup.xlPrimary), Word.Axis)
AxisY.HasTitle = True
AxisY.AxisTitle.Text = "Erreurs en µm"
Dim AxisX As Word.Axis = CType(oChart.Axes(Word.XlAxisType.xlCategory, Word.XlAxisGroup.xlPrimary), Word.Axis)
AxisX.HasTitle = True
AxisX.AxisTitle.Text = "Numéro de mesure"
oChart.HasTitle = True
oChart.ChartTitle.Font.Size = 18
oChart.ChartTitle.Font.Color = Color.Black.ToArgb()
oChart.ChartTitle.Text = "Analyse de tendance"
oChart.ChartTitle.Format.Line.Visible = Microsoft.Office.Core.MsoTriState.msoTrue
oChart.ChartTitle.Format.Line.ForeColor.RGB = Color.Black.ToArgb()
Dim obj = oChart.SeriesCollection(1)
Dim ser As Word.Series = TryCast(obj, Word.Series)
'ser.MarkerStyle = Word.XlMarkerStyle.xlMarkerStyleSquare
'ser.MarkerSize = 4
'Mise à jour table des matières
oWord.ActiveDocument.TablesOfContents(1).Update()
'Enregistre le doucment et ferme word
oWord.ActiveDocument.SaveAs(PathTemporaire & "\Mesures\Fichiers PDF\Rapport " & NomUtilisateur & ".docx")
oWord.ActiveDocument.Close()
oWord.Quit() |
Partager