Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1254
  • Last Modified:

Using LotusScript to get word count MS Word

I'm using code in LotusScritp to get the word count from a Word document. Briefly, w/o the error stuff it's just

     Set application = createobject("Word.Basic.8")
     Application.FileOpen(filename)
     wordCount = Application.GetDocumentProperty("Words")

This works, but the wordCount is not accurate.  I see from MS Knowledge Base 159791 that it's more accurate to get from Tools Word count dialog. They suggest.

     set wdDTWC = Dialogs(wdDialogToolsWordCount)
     wdDTWC.Execute
     dlgwordcount$ = wdDTWC.Words.

This works fine if your in Word and have a document open.  But how to you get this value from LotusScript using the application object?  

A more general question.  Is there a reference somewhere that lists everything you can call from the application object for Word in LotusScript?  Most of the stuff I try to do is not available and the commands that do work are usually different than what's in VBA in Word.

0
jsowle
Asked:
jsowle
  • 4
  • 3
1 Solution
 
ZvonkoSystems architectCommented:
In Designer you have to switch to OLE Classes list.
There you can see all OLE servers, their properties and methods with parameter types.

You see the OLE Classes only when you click to objects which support LotusScript. For example you click in a Form on QueryOpen event and you can select OLE Classes. Or you can see it always in LotusScript agents.

Good luck,
Zvonko


0
 
ZvonkoSystems architectCommented:
Oh, and you need the Word constants.

Const wdDialogToolsWordCount = 228 '\\(&HE4)

So the complet script looks like this:

Sub Click(Source As Button)
     filename="F:\Zvonko\tmp\frahp_010103.doc"
     Set WordApp = createobject("Word.Application")
     WordApp.Documents.Add(filename)
     Const wdDialogToolsWordCount = 228 '(&HE4)
     Set wdDTWC = WordApp.Dialogs(wdDialogToolsWordCount)
     wdDTWC.Execute
     dlgwordcount$ = wdDTWC.Words
     Msgbox "Words: " & dlgwordcount$
End Sub





0
 
jsowleAuthor Commented:
Great.  I had never used that part of the designer.  However I don't see in there anyway to get the actual methods and properties I need.  For instance "GetDocumentProperty" is not included anywhere that I can find.  I'm trying

Dim temp As Variant
Set temp = application.Dialog("wdDialogToolsWordCount")    
Call temp.execute
wordCount = temp.Words

But "execute is not an instance of temp"
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jsowleAuthor Commented:
We crossed communications.  I get Instance Dialogs does not exist with your code.  I think that must be because I'm using Word.Basic.8 instead of Word.Application for createobject.  Is there an equivalent for the dialogs command in WB 8?  If not, I'm also going to have to replace a bunch of other stuff.

e.g.

Call application.StartOfDocument
Call application.EditFindClearFormatting
Call application.EditFindStyle("DocName")
Call application.EditFind("L:*","L:",0,0,0,1,0,0,1,0)
If application.EditFindFound = -1 Then
     Print "Document name found,  Adding TTN"
     Call application.EndOfLine()
     Call application.Insert(" (TTN " & docTTN & ")")
End If

I think I have seen an MS site which has replacement commands for WB8
0
 
ZvonkoSystems architectCommented:
Moment please, we are here in LotusNotes topic area.
You asked how to call VB from LotusScript and I did show you some lookup methods.

Now you ask why Word.Application methods do not work in Word.Basic because you like the Work.Application code running but don't like to change Word.Basic part. Huh!!!

Hey, what is the problem to do WordsCount by using Word.Application and let the rest as is???

0
 
jsowleAuthor Commented:
Don't get mad.  Sorry.  I was previously under the impression that you had to use Word Basic 8 commands in LotusScript.  I guess that was true in 4.5 but not in 5.x???  I'm beginning to get the picture.  I think I can figure it out from here.  You've been very helpful....and fast too. Thanks.
0
 
ZvonkoSystems architectCommented:
You are welcome :-)

Small side note: LotusScript is an own extension of Visual Basic.
It has own classes and syntax extensions.
But it can communicate with other OLE interfaces and call their methods and change their property values.

If this is enough for you then grant please an A grading to one of my comments as an answer.

Thanks,
Zvonko

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now