Private Sub CommandButton1_Click()
With CreateObject("Word.Application")
.Documents.Add
.Selection.Font.Italic = 9999998 'wdToggle
.Selection.ParagraphFormat.Alignment = 1 'wdAlignParagraphCenter
.Selection.TypeText Text:="Hello world"
.Visible = True
.Activate
End With
End Sub
создать word-документ из excel
Есть задача из excel-документа создать цword-документ. Делаю так:
Private Sub CommandButton1_Click()
Dim wrd As Object
Dim adoc As Object
Set wrd = CreateObject("Word.Application")
wrd.Documents.Add
Set adoc = wrd.ActiveDocument
wrd.Selection.Font.Italic = wdToggle
wrd.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
wrd.Selection.TypeText Text:="Hello world"
wrd.Selection.Font.Italic = wdToggle
wrd.Visible = True
wrd.Activate
End Sub
проблема такая - строка "Hello world" не выравнивается по центру и не пиштся курсивом! Не могу разобраться почему...
спасибо всем
Код:
Или же :
Код:
Private Sub CommandButton1_Click()
Const wdAlignParagraphCenter = 1
Const wdToggle = 9999998
With CreateObject("Word.Application")
.Documents.Add
.Selection.Font.Italic = wdToggle
.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Selection.TypeText Text:="Hello world"
.Visible = True
.Activate
End With
End Sub
Const wdAlignParagraphCenter = 1
Const wdToggle = 9999998
With CreateObject("Word.Application")
.Documents.Add
.Selection.Font.Italic = wdToggle
.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Selection.TypeText Text:="Hello world"
.Visible = True
.Activate
End With
End Sub