Office Automation Using C - TechRepublic
General discussion
July 31, 2003 at 03:14 PM
jackofalltech

Office Automation Using C

by jackofalltech . Updated 22 years, 10 months ago

Can this be done in C?

Sub Main()
Dim oWord As Object
Dim oDoc As Object
Dim oRange As Object
Dim oPara As Object

Set oWord = CreateObject(“Word.Application”)
With oWord
.WindowState = wdWindowStateMaximize
.Documents.Add
Set oDoc = oWord.ActiveDocument
Set oRange = oDoc.Range
With oRange
.Font.Bold = True
.Font.Italic = True
.Font.Size = 16
.InsertAfter “RunningWord From VB Using Automation”
.InsertParagraphAfter
‘Insert a blank paragraph between the two paragraphs
.InsertParagraphAfter
End With

Set oPara = oRange.Paragraphs(3)
With oPara.Range
.Bold = True
.Italic = False
.Font.Size = 12
.InsertAfter “Report Created: ”
.Collapse Direction:=wdCollapseEnd
.InsertDateTime DateTimeFormat:=”MM-DD-YY HH:MM:SS” End With

.ActiveDocument.SaveAs “D:\Download\autCreateDate.Doc”
.Quit
End With

Set oWord = Nothing
Set oDoc = Nothing
Set oRange = Nothing
Set oPara = Nothing
End Sub

This discussion is locked

All Comments