uses errors to learn whether Word is already open before pasting a chart at the end of a document. If not, it opens Word and creates a new document: : Word « Word « VBA / Excel / Access / Word






uses errors to learn whether Word is already open before pasting a chart at the end of a document. If not, it opens Word and creates a new document:

 
Sub IsWordOpen()
    Dim wdApp As Word.Application
    ActiveChart.ChartArea.Copy
    On Error Resume Next
    Set wdApp = GetObject(, "Word.Application")
    If wdApp Is Nothing Then
        Set wdApp = GetObject("", "Word.Application")
        With wdApp
            .Documents.Add
            .Visible = True
        End With
    End If
    On Error GoTo 0
    
    With wdApp.Selection
        .EndKey Unit:=wdStory
        .TypeParagraph
        .PasteSpecial Link:=False, DataType:=wdPasteOLEObject, _
            Placement:=wdInLine, DisplayAsIcon:=False
    End With
    
    Set wdApp = Nothing
End Sub

 








Related examples in the same category

1.Check the word version
2.The Word object that's created is invisible. If you'd like to see the object while it's being manipulated, set its Visible property to True, as follows: