Question

I hate word automation....

Asked by: caraf_g

Hi there.

I just can't seem to find any decent documentation. I have a word document. In this document there is a bit of text, say

[[Surname]]

What I want to do through Word Automation is to find that bit of text, and then replace it with a Form Field.

How does one go about doing *that*?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2002-08-22 at 04:48:06ID20339734
Tags

word

,

automation

Topic

Visual Basic Programming

Participating Experts
9
Points
200
Comments
26

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. word automation
    Hi I am writing a small vb program with Access database. I want to populate a word document with some data from Access database like Customer's Name and Address. I know how to open the word document with ole automation but I don't know how to populate some areas in document....

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: calacucciaPosted on 2002-08-22 at 04:53:09ID: 7235750

Hi Pino,

Some advise from a VB amateur, and an Office amateur:

Try this:

Sub Find_en_make_ff_voorPino()
Dim myFF As FormField
Selection.HomeKey wdStory
With Selection.Find
    .Text = "Surname"
    .Execute
End With
Set myFF = Selection.FormFields.Add(Selection.Range, wdFieldFormTextInput)
myFF.Result = "Surname"
End Sub

I'll leave eventual argument functionality to your imagination.

 

by: calacucciaPosted on 2002-08-22 at 05:00:15ID: 7235765

I suppose you know that to make these commands work from within VB you need to precede all Word command by the Word.Document object.

 

by: caraf_gPosted on 2002-08-22 at 05:01:11ID: 7235772

but of course....

Hee Geert - long time no hear....

:)

I'll check it out.

 

by: mnasmanPosted on 2002-08-22 at 05:12:52ID: 7235805

for good documenations for word automation

look at
http://www.microsoft.com/officedev/articles/Opg/007/007.htm

 

by: caraf_gPosted on 2002-08-22 at 05:16:37ID: 7235816

Hey - I have another question about Word Automation, er, <cough> "elsewhere".... perhaps you might want to look at that?

 

by: calacucciaPosted on 2002-08-22 at 05:21:16ID: 7235832

Yes, of course.

I have been completely absent of EE, but recently saw the new look, and before you know, back answering questions ;-)

 

by: caraf_gPosted on 2002-08-22 at 05:37:41ID: 7235867

LOL - I saw the new look too. Thankfully there weren't any razorblades near....

 

by: angelIIIPosted on 2002-08-22 at 05:43:50ID: 7235885

Hi,

  If you want to find all [[...]], use this:

  With Selection.Find
   .UseWildCards= true
   .Text = "\[\[*\]\]"
  End With
  'attention at this line, don't include it in the WITH block !!!! otherwise you will office automation even more :-)
  while Selection.Find.Execute
    ....
  wend

CHeers

 

by: caraf_gPosted on 2002-08-22 at 06:09:35ID: 7235949

Angel, I was *just* going to ask something like that !

:)

Damn. I wish you could split points here like you can on some other site I wont' mention.

 

by: EDDYKTPosted on 2002-08-22 at 06:14:54ID: 7235968

Have you tried to use 'record the macro'?

 

by: angelIIIPosted on 2002-08-22 at 06:18:08ID: 7235975

:-))
Don't mind the points...

 

by: angelIIIPosted on 2002-08-22 at 06:19:14ID: 7235978

So you have noticed that I started answering question that have not even been posted ...
CHeers

 

by: NitinSontakkePosted on 2002-08-22 at 06:24:25ID: 7235991

As to a detailed documentation on Word Object Model why not search for VBA*.CHM files in your MS-Office directory. You will find one for Word, Excel, etc.

 

by: calacucciaPosted on 2002-08-22 at 06:39:33ID: 7236040

pino,

How is the site that we can't mention running, a lot of activity? It seems that a lot of topics are quite empty for the moment, which is a pity looking at the work you accomplished.

 

by: caraf_gPosted on 2002-08-22 at 06:52:25ID: 7236077

Not too bad, Geert, remember that threads don't necessarily get archived there.

Lounge is quite busy. Other areas are very slowly gathering steam. I think it'll get there. Eventually.

WTF is the timeout on this site? I type a comment - "resource not available" !?>!:?

 

by: calacucciaPosted on 2002-08-22 at 07:06:16ID: 7236107

NFI !

I have noticed that instead of the good old jsp pages thrown at us, now from time to time a page remains black without text on parts of it and nothing happens...

 

by: mcoopPosted on 2002-08-22 at 14:55:24ID: 7237206

EDDYKT has the best idea...

Use Word to record a macro - work it over in Word until it does most of what you want, then you have about 80% of your word automation code.

 

by: pierrecampePosted on 2002-08-22 at 17:20:09ID: 7237435

yes use the recorder
and leave the macro in word
and call the macro from your vb program
its a lot faster and easier

 

by: caraf_gPosted on 2002-08-23 at 00:46:42ID: 7237887

Leaving macros in word are not an option as some of our customers may have rather strict security settings. But using a macro to record stuff for later reference sounds like the sort of pragmatic approach that I like :)

 

by: calacucciaPosted on 2002-08-23 at 01:29:10ID: 7237971

Excuse me people, but why would one record a macro except for learning how certain obscure command are hidden inside Office VBA applications?

For the kind of Task Pino is after here, (the use of the Formfields.Result property is the only viable one for filling out formfields), the correct property cannot be recorded by a macro.

It is good to use it, but in the end you'll need to twist the generated code around and reuse it in a right and efficient way.

 

by: DanRollinsPosted on 2003-03-16 at 14:48:12ID: 8147859

Hi caraf_g,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept calacuccia's comment(s) as an answer.

caraf_g, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer

 

by: caraf_gPosted on 2003-03-18 at 00:37:08ID: 8157662

Hi Dan,

Like Idi Amin said: "Don't meddle in things you don't understand".

Although I can't honestly say I give two hoots as to what happens to this question, I don't think calacuccia answered the question even though his comments were much appreciated.

 

by: acperkinsPosted on 2003-03-18 at 07:44:06ID: 8159725

Come on Pino, be fair:  Dan is doing a thankless job in a thankless place.  Put yourself in his position and had to pick an answer, how would you judge the answers to this question.  

Anthony

 

by: caraf_gPosted on 2003-03-18 at 08:24:54ID: 8160098

acperkins, if I were to put myself in Dan's position I would have the decency not to sign comments like the above with an official-looking "EE Signature". It pisses me off.

Anyway - because there certainly are no hard feelings toward calacuccia I've increased the points to 200 and I've awarded the Q to him.

;P

 

by: DanRollinsPosted on 2003-03-18 at 09:11:17ID: 8160486

caraf_g and acperkins,
Thanks for your continuing support.
-- Dan

 

by: caraf_gPosted on 2003-03-19 at 04:59:24ID: 8166213

Hm.... Thanks Dan!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...