How to hide Excel When processing a Word.Chart In Word



Dear experts,

I hope to creat charts in Microsoft Word. I know Microsoft Office 2007
SP2 and Office 2010 provide the new object model Wor.Chart. Everything
is good except the Microsoft Excel always appears. The Microsoft Excel
will appear when I run ChartData.Activate. I just can hide the
Microsoft Excel after this step. Is there any way to hide Microsoft
Excel during the whole processing?

The code:

Dim wdApplication As Microsoft.Office.Interop.Word.Application =
Dim wdDocument As Microsoft.Office.Interop.Word.Document = Nothing
Dim wdChart As Microsoft.Office.Interop.Word.Chart = Nothing
Dim xlWorkbook As Microsoft.Office.Interop.Excel.Workbook = Nothing

wdChart = wdDocument.InlineShapes(1).Chart
With wdChart.ChartData
.Activate() ' Microsoft Excel will appear. This is the problem.
xlWorkbook = .Workbook
End With
If xlWorkbook Is Nothing Then
Exit Function
End If
With xlWorkbook.Application
.Visible = False ' Hide Microsoft Excel
.ScreenUpdating = False
' Put data into Worksheets
End With

Liu Jianzhong


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question