Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
7
Erster Beitrag:
vor 2 Jahren, 8 Monaten
Letzter Beitrag:
vor 2 Jahren, 8 Monaten
Beteiligte Autoren:
newbie1, Fabrice Harari, Stewart Crisler

turtorial exampel controlling word

Startbeitrag von newbie1 am 11.06.2015 18:53

hello,
this weekend i had a look at the exampel controling word....the features looked promising,..
find/replace...write line...
however for my purpose i need to go to a certain position and write a textline i also need a way to retrieve at what position the cusor stands(in the controlled word doc)...however in the Cword class that is provided there is no function to do this (in my case find / replace just issent enough).

any help is appreciated
thanks in advance

Antworten:

Hi

the usual way of doing these things is as follow:
- in word, start recording a macro
- do what you need to do (by example "go to a certain position and write a textline ")
- stop the macro
- edit the macro and TRANSLATE the VBA code into wlanguage

Best regards

von Fabrice Harari - am 11.06.2015 19:18
would running a macro recordit on 1 pc work on another?with difrent screen reolution/changed desktop gui?

is this what the Cword clas does when it uses string replace?

von newbie1 - am 11.06.2015 20:30
Hi again
yes, a macro recorded on one pc would work on another...

no, it doesn't USE a macro, it uses wlanguage code that matches (has been translated) from the corresponding functions in VBA

Best regards

von Fabrice Harari - am 12.06.2015 12:44
Word offers document variables. You can put these variables wherever you need to insert stuff into a document. You can then use COM automation to replace the variable with whatever text. I have used this technique for generating insurance policies since 1997 with Visual Foxpro as the driver program. I'm very confident WinDev could accomplish the same thing. It's a fully programmed control mail merge. Unfortunately I do not have the exact method of the COM object to call available to me but it exits and works very reliably.

Stewart Crisler

von Stewart Crisler - am 12.06.2015 17:11
after some search i found the folowing code
however i seem to have some issues on translating it in W5
how can i make a class of it ?


Const wdStory = 6
Const wdMove = 0

Set objWord = CreateObject("Word.Application")
objWord.Visible = True

Set objDoc = objWord.Documents.Open("c:\scripts\testdoc.doc")

Set objSelection = objWord.Selection
objSelection.EndKey wdStory, wdMove

objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeText "This text was appended to an existing Word document."


source


von newbie1 - am 12.06.2015 20:10
no one who knows how i can translate this vba code to W5,?

von newbie1 - am 13.06.2015 17:27
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.