Home | Careers | IT Counseling | IT Jobs | IT Resources

 

 

 
About Us | Advertise | Feedback | Contact Us | Bookmark this page now|
Have any doubts regarding how to Search IT Training Courses?...Click here for Quick Search Tips Search IT Courses
Have any doubts regarding Keyword Search?...Click here for Quick Search Tips keyword
Have any doubts regarding Institutes Search?...Click here for Quick Search Tips institutes
Have any doubts regarding Specialization Search?...Click here for Quick Search Tips specialization
Have any doubts regarding Fees Search?...Click here for Quick Search Tips fees
to
Have any doubts regarding Duration Search?...Click here for Quick Search Tips duration

IT dart Tips

Which IT course ?

Venture Capital

Online Education

Exams Required for US of A

Overview of Admission Process

Test Preparation

Financial Aid

TOEFEL Examination

Cool Interview Tips

Skill Check

Resume

GRE Examination

GMAT Examination


IT dart News Letter
Get ITdart.com weekly headlines before it's published on our site! Subscribe and receive the articles delivered to your inbox!

Learning MS Word object model

As you must have realised by now, the programmability of Word is vast and extensive. To remember all the features of all objects is not only close to impossible but is impractical as well. Therefore, you need to have some quick method of learning more about the objects and their properties.

There are two methods to accomplish this:

Learn from the Help file of Word VBA.
Learn from macros automatically recorded by Word.
Learning from the Help file:

This would be simple if you knew which object or method you wanted to access. You can also traverse the object model and go deeper into objects, methods and properties. This provides you with syntax and sample code in most cases.

Unfortunately, the Help file is not always useful as some syntactical elements are not very intuitive. In addition some tasks require multiple steps which are not mentioned in the Help file in that particular order. Here the second method comes in handy.

Learning from recorded macros:

Word has a powerful macro feature allowing you to create macros by recording the actions you perform. The macro is actually a VBA program that is created by Word depending upon the recorded actions. This program can be read and edited by you.

This recorded program is of immense help in learning the VBA-equivalent code of complex Word tasks.

Let us say we have a document where we want to convert the word 'Fox' to 'fox'. We want to programmatically change the font size, colour and replace all instances of the word 'Fox' with the new format. Let us first create a recorded macro.

Choose the Macro - Record New Macro... option from Word's Tools menu
Give a name to the macro, say, Sample.
Press Ctrl-Home to go to the beginning of the document.
Choose the Replace... option from the Edit menu.
Click the More button in the Find and Replace dialog box.
Type 'Fox' in the Find what: field.
Type 'fox' in the Replace with: field.
Now click the Format button.
Select Font... from the menu and select the required font. Mark the font size as 14 and colour as blue. When done, click OK.
Now click the Replace All button in the Find and Replace dialog box.
All instances of the word 'Fox' are replaced with the new word 'fox'.
Now let us see what was recorded by the Macro recorder:
Click the Stop button on the recorder toolbar.
Select Macro - Macros... from the Tools menu. Choose the Sample macro and click the Edit button.
Here's what the recorded code should look like:

Sub Sample()
'' Sample Macro
' Macro recorded 13/01/99 by Times Computing
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Size = 14
Selection.Find.Replacement.Font.ColorIndex = _
WdColorIndex.wdDarkBlue
With Selection.Find
.Text = "Fox"
.Replacement.Text = "fox"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Now you can follow this code line by line and understand the exact methodology a lot easier than having to refer to the Help file a number of times. You can also modify this code and try various other variations to learn more about the features in a shorter time span

One Click Courses

Advanced Certiflcate in Java Application Development

Advanced Cisco Router Conflguration

Advanced Course in Object Oriented Programming (Coop)

C#

C# with ASP.Net

CAD/ CAM

Certfication in Unix, C, C++ (CUCC)

Certificate in Advanced System Programming

Certificate in Java & E-commerce (CJEC)

EI -Strategiest

Object Oriented Developer and Designer

Specialization in 3D Graphics & Animation

Wap@Asset


Firewalls: What To Block

Windows System Architecture (WSA)

Operating System (OS)

Data Access Technologies

Functional menu-level blocking

Data Access Methodologies

ODBC Architecture

Learn Java from the ground up

Internet Security

The Day I Learnt JavaScript



ITdart Updates:
Computer Security | Computer Services | CRM | Database | E Commerce | Graphic & Design | Internet | Java | Knowledge Management | Linux | Online Marketing | Open Source | Operating System | Robotics | Semi Conductors | Software Downloads | Virus Info | WAP & 3G | Web Development | XML and Metadata
Home | Careers | IT Counseling | IT Jobs | IT Resources

© Copyright 1999-2000 ITdart.com. All rights reserved.
All brands are Trade Marks of Respective owners. Disclaimer    Legal    Privacy Policy