Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Dim WrdApp As Word.Application
Dim WrdDoc As Word.Document
Dim MSCht As Word.InlineShape
Dim oGraph As Object
Dim oDataSheet As Object
Set WrdApp = New Word.Application
WrdApp.Visible = True
Set WrdDoc = App.Documents.Add
Set MSCht = Selection.InlineShapes.AddOLEObject(ClassType:="MSGraph.Chart", _
LinkToFile:=False, DisplayAsIcon:=False)
' Find Chart Object
Set oGraph = WrdDoc.InlineShapes(1).OLEFormat.object
With oGraph.Application.Chart
.ChartType = xlColumnClustered
.Axes(xlCategory).HasMajorGridlines = True
.Axes(xlCategory).HasMinorGridlines = False
.HasTitle = True
.ChartTitle.Text = "Title Here"
.HasLegend = True
.Legend.Font.ColorIndex = 5
.Legend.Font.Size = 8
.Legend.Height = 72 * 2
.Legend.Width = 72 * 3
.ApplyDataLabels
.SeriesCollection(1).HasDataLabels = True
.SeriesCollection(1).DataLabels.Font.Size = 10 - UBound(arrTemp)
.SeriesCollection(1).DataLabels.Font.Color = RGB(255, 255, 255)
.SeriesCollection(1).DataLabels.AutoScaleFont = False
.SeriesCollection(1).DataLabels.Position = xlLabelPositionInsideEnd
End With
Set oDataSheet = oGraph.Application.DataSheet
' Clear the datasheet.
oDataSheet.Cells.Clear
' set series
oDataSheet.Cells(1, 2).Value = "Category"
oDataSheet.Cells(2, 2).Value = 6 ' Value
oDataSheet.Cells(2, 2).NumberFormat = "#.00"
oGraph.Application.Quit
Set oGraph = Nothing
Set WrdDoc = Nothing
Set WrdApp = Nothing
For i = 0 To Doc.InlineShapes.Count
strName = CStr(Doc.InlineShapes(i).OLEFormat.ClassType)
If InStr(1, strName, "MSGraph") > 0 Then
Set oShape = Doc.InlineShapes(i)
End If
Next
if not oShape is nothing then
'... found the chart
end if