Helmut
Mon Mar 14 07:33:09 CST 2005
Hi,
(reference to excel-library needed,
extras references),
then
lets say you have an excel worksheet,
with "size" in one of the cells in the first row,
with the values 8, 9, 10, 11, 12 in the following rows
in the same column.
then
create a new excel.application,
open the workbook in question,
select the first row in the first worksheet
which gives you the column to search
and while the next cell in the same column
contains data, format e.g. the corresonding
paragraph in you doc in the font.size read
from the excel sheet.
If you decide to set the excel.application
to visible = false, then make sure to destroy
both the objects excel.application und excel.workbook
before the end of your macro.
My code is in no way optimized.
I just wanted to show the very basics.
Beware of linebreaks by the newsreader
' ----------
Dim r As Long ' row
Dim c As Long ' column
Dim oExc As Excel.Application
Dim wExc As Excel.Workbook
Set oExc = New Excel.Application
Set wExc = oExc.Workbooks.Open("c:\test\fontbook.xls")
oExc.Visible = True
wExc.Worksheets(1).Rows("1:1").Select
oExc.Selection.Find(What:="Size").Activate
r = oExc.ActiveCell.Row
c = oExc.ActiveCell.Column
r = r + 1
With wExc.Worksheets(1)
While .Cells(r, c).Value <> ""
ActiveDocument.Range.Paragraphs(r -
1).Range.Font.Size = .Cells(r, c).Value
r = r + 1
Wend
End With
' ...
End Sub
' ----------
See, too:
http://www.word.mvps.org/faqs/interdev/ControlXLFromWord.ht
m
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000