VBA/Excel/Access/Word/Word/Word — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:33, 26 мая 2010
Check the word version
Sub GetWordVersion()
Dim WordApp As Object
Set WordApp = CreateObject("Word.Application")
MsgBox WordApp.Version
WordApp.Quit
Set WordApp = Nothing
End Sub
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:
Sub GetWordVersion()
Dim WordApp As Object
Set WordApp = CreateObject("Word.Application")
MsgBox WordApp.Version
WordApp.Visible = True
WordApp.Quit
Set WordApp = Nothing
End Sub
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