M
Mel_la_Bel
Hello all,
I have a problem with VB.Net.
I want to get the readabilityStatistics from word documents. herefore I have
to activate a doc as an ActiveDocument in the Word.Application. And here is
exactly the problem. I cannot use the ActiveDocument as it is written
everywhere in the MSDN!
Here is what I did:
....
Private Sub TestMSWordFunc(ByVal file As String)
'MS Word declarations
Dim wordApp_Server As Word.Application
Dim wordDoc As Word.Document
Dim wordRange As Word.Range
Dim wordStatistic As Word.ReadabilityStatistic
'Other
Dim fileMod As Boolean
Dim resComputeStatistics As Integer
Dim wordEnum As IEnumerator
Dim wordVal As ValueType
'Open an application server first
wordApp_Server = New Word.Application
wordDoc = wordApp_Server.Documents.Open( _
FileName:=file, _
ConfirmConversions:=False, _
ReadOnly:=False, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
Revert:=False, _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Format:=Word.WdOpenFormat.wdOpenFormatAuto, _
Visible:=False)
'Document must be set active in order to retrieve further information
wordApp_Server.Documents.Add(file)
wordDoc = wordApp_Server.ActiveDocument
Label_ResultFile.Text = file
Label_ResultWords.Text =
wordDoc.ComputeStatistics(Word.WdStatistic.wdStatisticWords)
Label_ResultParagraphs.Text =
wordDoc.ComputeStatistics(Word.WdStatistic.wdStatisticParagraphs)
Label_ResultFK.Text =
wordApp_Server.ActiveDocument.Content.ReadabilityStatistics.Item(6).Value
....
I cannot get to tell the application the open word document!! The last line
always returns zero, as the ActiveDocument is empty,i.e. a different document
than the one I opened!
Can anybody help me?
I am getting crazy. It is probably very easy, but I cannot see the mistake.
Kisses
Mel
I have a problem with VB.Net.
I want to get the readabilityStatistics from word documents. herefore I have
to activate a doc as an ActiveDocument in the Word.Application. And here is
exactly the problem. I cannot use the ActiveDocument as it is written
everywhere in the MSDN!
Here is what I did:
....
Private Sub TestMSWordFunc(ByVal file As String)
'MS Word declarations
Dim wordApp_Server As Word.Application
Dim wordDoc As Word.Document
Dim wordRange As Word.Range
Dim wordStatistic As Word.ReadabilityStatistic
'Other
Dim fileMod As Boolean
Dim resComputeStatistics As Integer
Dim wordEnum As IEnumerator
Dim wordVal As ValueType
'Open an application server first
wordApp_Server = New Word.Application
wordDoc = wordApp_Server.Documents.Open( _
FileName:=file, _
ConfirmConversions:=False, _
ReadOnly:=False, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
Revert:=False, _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Format:=Word.WdOpenFormat.wdOpenFormatAuto, _
Visible:=False)
'Document must be set active in order to retrieve further information
wordApp_Server.Documents.Add(file)
wordDoc = wordApp_Server.ActiveDocument
Label_ResultFile.Text = file
Label_ResultWords.Text =
wordDoc.ComputeStatistics(Word.WdStatistic.wdStatisticWords)
Label_ResultParagraphs.Text =
wordDoc.ComputeStatistics(Word.WdStatistic.wdStatisticParagraphs)
Label_ResultFK.Text =
wordApp_Server.ActiveDocument.Content.ReadabilityStatistics.Item(6).Value
....
I cannot get to tell the application the open word document!! The last line
always returns zero, as the ActiveDocument is empty,i.e. a different document
than the one I opened!
Can anybody help me?
I am getting crazy. It is probably very easy, but I cannot see the mistake.
Kisses
Mel