Ye olde Font.Position problem with non-integers...

D

david

Hello everyone,

After much research, I've finally figured out why the parameters I was
giving my script for positioning InlineShapes according to certain
values was slightly off: .Position only takes integers! After digging
some more, I came across someone's brilliant idea to use the old
WordBasic command syntax which supposedly doesn't have this problem.
But I can't get the commands to work :-(

[snip some code]

Dim Form As InlineShape
Dim iVar As Variant
Dim Feld1() As String
Open ActiveDocument.Path + "\" & sCount & ".txt" For Input As #1
Text = Input(LOF(1), #1)
Feld1 = Split(Text, vbCrLf)
Close #1
Anz = ActiveDocument.InlineShapes.Count
For i = 1 To Anz
iVar = Val(Feld1(i - 1))
Set Form = ActiveDocument.InlineShapes(i)
' Form.Range.Font.Position = iVar
WordBasic.FormatFont Position:=iVar
Next i

Is there a different sort of command syntax involved? Must I "select"
the InlineShape first? Or am I barking up the wrong tree?
Thanks in advance
David
 
H

Helmut Weber

Hi David,

and what is it, that goes wrong?

First, split returns a zero based array.

Second, when passing a single to .Font.Position
having read the value form a text file
with possibly regional standards of spelling,
2,5 vs 2.5, as "Feld1" looks very much much like german to me,
you may encounter more problems.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
D

david

Hi Helmut,
and what is it, that goes wrong?

Well... this works as expected:
Form.Range.Font.Position = iVar

This, on the other hand, does absolutely nothing, not even an error
message:
WordBasic.FormatFont Position:=iVar

And so I would appreciate if soemone could tell me the necessary
parameters , if any.
First, split returns a zero based array.

I know... but the text file is just a simple list of numerical values
which give the desired position for the corresponding Inlineshapes,
e.g.
-9.5
-5.0
-7.0
and so on. It seemed simpler than ReDim :)
Second, when passing a single to .Font.Position
having read the value form a text file
with possibly regional standards of spelling,
2,5 vs 2.5, as "Feld1" looks very much much like german to me,
you may encounter more problems.

All the text files are formatted the same way, so I'm not really
worried about exceptions; but I am worried that I can't assign precise
values to the different Inlineshapes. Always rounding pt-values is a
bit of a bother...

I know this is a somewhat esoteric problem, but maybe there's a
solution out there... one that I can understand :)

All the best
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top