Formatting text in Word with Excel VBA

Billy Bong

New Member
Joined
Jan 24, 2005
Messages
1
Hello,

Right now, I have a Excel file that export the content of specified cells to a Word document. To maintain a certain order in the data that i'm exporting, I used two collections of range() that represent the objectifs and the associated answer.

Here's my problem, once the objectifs is exported to word I would like to select the line and apply formatting to it (i.e Arial 14 Bold). But since I'm using collection instead of a copy/paste method, I'm can't find the neccessary code to select the line I want to format.

Could anybody help me

Thanks

Billy Bong
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
Hi Billy,

Since VBA, whether in Word or Excel, can access the entire Word object model, it is really a matter of deciding the best way to look for the data. Probably the easiest way to find data in Word from VBA is to place a bookmark where the data is located (or will be inserted) or to place the data in a Word table where its location can be expressed as a table name and cell row and column indices. But you can also search for a text string using the Word Find capability, or if you know the number of the paragraph section, etc., these can be used to find the data. You might start by asking yourself the question: "if the document were 1000 pages long, how would I find the line you want to format manually?"

Once you settle on how you want to find the line you want to format, implementing it in VBA should be a snap.

Damon
 

Forum statistics

Threads
1,147,845
Messages
5,743,513
Members
423,801
Latest member
paulj4177

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top