finding text based on style in MSWord
finding text based on style in MSWord
finding text based on style in MSWord
finding text based on style in MSWord
finding text based on style in MSWord
finding text based on style in MSWord finding text based on style in MSWord finding text based on style in MSWord finding text based on style in MSWord finding text based on style in MSWord finding text based on style in MSWord finding text based on style in MSWord finding text based on style in MSWord
finding text based on style in MSWord finding text based on style in MSWord
finding text based on style in MSWord
Go Back  Xtreme Visual Basic Talk > > > finding text based on style in MSWord


Reply
 
Thread Tools Display Modes
  #1  
Old 02-17-2005, 04:37 AM
somerset_mike somerset_mike is offline
Newcomer
 
Join Date: Feb 2005
Posts: 1
Default finding text based on style in MSWord


Hi.

I need to edit a number of very large word documents (300 pages long). I need to insert text into lines based on heading styles.

Eg I need to move through the document and every time heading 3 appears enter text “xyz” at the start of the line.

If your kind enough to help please be aware that I’m still relatively new to using VBA so please feel free spell things out. Also because of the way our network is set up I have to do the whole edit thought an independent program (created using VB .net), we can’t use macros.

It might help you to know that, so far I can insert text I can use ‘range’ and ‘selection’ and can open, save close documents.

kind regards

Mike
Reply With Quote
  #2  
Old 02-17-2005, 07:49 AM
herilane's Avatar
herilanefinding text based on style in MSWord herilane is offline
Unashamed geek

Retired Moderator
* Expert *
 
Join Date: Jul 2003
Location: London, England
Posts: 8,988
Default

Welcome to the forum.

Just to clarify some terminology - if you are using VB.Net then you are not using VBA. VBA is the built-in thing in Word, i.e. macros. There are many similarities (Word's object model is the same no matter which language you use) but some things that work in one won't work in the other, so it is important to be clear about which one you are using.

Even so - even though I've just told you that they are two different languages - I would recommend you to first learn how to do this in VBA, and then when you've got it working, port it to VB.Net. The main reason for this is that VBA is simpler, so you can focus on doing what you want to get done. In VB.Net all sorts of automation issues will get mixed up in the process. The other reason is that VBA lets you use the macro recorder.

So, first step: go to Word and record a macro while you do this manually. This will show you how to use the Find object to find text by style. You can read about the Find object in the VBA help files, and in the Word VBA FAQ thread.

Second step: clean it up. Convert from Selection to Range where possible, add whatever loops you need, etc.

Third step: port the code from VBA to VB.Net. Copy the code over, add proper referencing to all objects (Selection becomes objWordApp.Selection etc). Sort out any errors that still appear.

Hope this helps; report back if/when you run into trouble.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
finding text based on style in MSWord
finding text based on style in MSWord
finding text based on style in MSWord finding text based on style in MSWord
finding text based on style in MSWord
finding text based on style in MSWord
finding text based on style in MSWord finding text based on style in MSWord finding text based on style in MSWord finding text based on style in MSWord finding text based on style in MSWord finding text based on style in MSWord finding text based on style in MSWord
finding text based on style in MSWord
finding text based on style in MSWord
 
finding text based on style in MSWord
finding text based on style in MSWord
 
-->