What is the best way to call MSWord from C ++
I have never done this before. I have always used VB6 and Word-COM-Library:C:\Program Files\Microsoft Office\OfficeXX\MSWORD.olb
Respectively:
Microsoft Word XX.0 Object Library
- How do I use / call Word from C ++ (VS2010)?
- Should I use .NET? (C ++ CLI)
- Do you have a good step by step explanation?
Sample code in VB
Option Explicit
Sub Main()
Dim mWord As New Word.Application
mWord.ScreenUpdating = False
Dim mMaxParagraph As Long
Dim aDoc As Word.Document
Dim aFileName As String
aFileName = "C:\mydoc.doc"
Set aDoc = mWord.Documents.Open(aFileName)
mMaxParagraph = mWord.ActiveDocument.Paragraphs.Count
Debug.Print CStr(mMaxParagraph)
aDoc.Close
mWord.Quit
End Sub
source
share