Solved What is the correct way to linearly insert text into Word? (1 Viewer)

Isaac

Lifelong Learner
Local time
Today, 08:47
Joined
Mar 14, 2017
Messages
8,777
I'm with Doc. Whenever I try to automate Word (Excel is less bad), I feel like I'm playing pin-the-tail on the donkey and I'm the donkey.

I did manage to create a Word document from COBOL by using the .rtf format. Since this method is plain text and is done with begin/end tags, once i found the RTF spec on line and got a grip on the tags I needed, it was fairly straight forward. My task was to create a report that I could email as a Word attachment so the formatting wasn't too crazy. When I couldn't figure out the tags, I created a Word doc in .rtf format and did the formatting there. Then I opened the .rtf using NotePad to see the tags.

Wiki has a good overview

Here's the final spec for version 1.9.1
file:///C:/Data/UsefulDatabases/WordRTFDocumentation/[MSFT-RTF].pdf

Word is interesting and seems very dodgy to me, but I can't be certain that's attributed to my lack of skill or that it really is pretty dodgy.
Excel can be automated to absolute and total precision.

I spent the first few years of my tech life "doing everything" using Excel vba and gosh darn it, by the time I learned other tools I had indeed learned how to smash everything into the shape of a nail if need be. Torturing metaphors there, sorry
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:47
Joined
Feb 19, 2002
Messages
43,275
I also feel much more grounded when automating Excel since at least it has some semblance of a rational object model. But Word gives me the dry heaves. At least using OLE to do fill bookmarks was rational because the bookmarks were named objects. Not so any more with the newer objects which is why I still use legacy objects. Who wants to figure out what goes in control 83?
 

Minty

AWF VIP
Local time
Today, 16:47
Joined
Jul 26, 2013
Messages
10,371
Powerpoint automation is equally flakey.

Long routines that run fine 95% of the time will error out, normally with an "Object not defined" or when trying to activate chart data worksheets "Object not available" or some other similarly vague message.

Even more frustratingly, if you click continue, it carries on running completes the action it said it couldn't and works until the next random error. Go figure.

It also slows down significantly if you have had things open for a while. One routine that updates 8 different sets of slides, if you reboot before setting it off takes approx 4 minutes per set. The last time I ran it this week (forgetting to reboot), it took 1 hour 20 minutes. 🤦‍♂️
 

SHANEMAC51

Active member
Local time
Today, 18:47
Joined
Jan 28, 2022
Messages
310
I did manage to create a Word document from COBOL by using the .rtf format.
since the days of FoxPro DOS, I have been doing the bulk of reports in HTML format (in the main 20-40 tags) from all ACCESS, EXCEL,....
- code visibility
- convenient to view in the browser
- opens for revision in EXCEL if necessary
- convenient to print in WORD - provides automatic selection of column widths and row heights
 

Users who are viewing this thread

Top Bottom