Applying style changes to contents of a file inserted at a bookmark

S

sylvian stone

Hi,

What I am attempting to do is probably very easy - but can't seem to
figure out.

Within a document, I use controls to insert other mini documents into
the document at specified bookmarks. However, some of these are using
different fonts, or they just don't come accross correctly.

Therefore, I defined a new Style (reportStyle) which I want to apply to
any new text that I import.

However, I just can't manage to achieve this. I think the main point I
am probably missing is to extend the range to the end of the text that
I have just inserted, then apply the style. I suspect all I am doing is
apply a style to a bookmark.

Any suggestions ?

Rgds
SS.

---------------Code Snippet Below -------------------

Dim myRange As Range

'Set Attitude to Investment Risk Paragraph

Set myRange = objDoc.Bookmarks("detailed_recommendations").Range
myRange.Style = objDoc.Styles("reportStyle")


Dim cCont As Control
Dim tempCntl As String
Dim tempCntlprovider As String
myRange.Style = objDoc.Styles("reportStyle")


For Each cCont In Me.Controls
'MsgBox TypeName(cCont) & " - " & cCont.Name
If TypeName(cCont) = "CheckBox" Then
If cCont.value = True Then
tempCntl = cCont.Name
tempCntlprovider = cCont.Name & "_provider"
If Me.Controls(tempCntlprovider).ListIndex <> 0 Then
myRange.InsertFile providerpath &
Me.Controls(tempCntlprovider).value & ".doc"
myRange.InsertFile detpath & tempCntl & ".doc"
myRange.Style = objDoc.Styles("reportStyle")
End If
End If
End If
Next cCont
 
C

Cindy M -WordMVP-

Hi Sylvian,
What I am attempting to do is probably very easy - but can't seem to
figure out.

Within a document, I use controls to insert other mini documents into
the document at specified bookmarks. However, some of these are using
different fonts, or they just don't come accross correctly.

Therefore, I defined a new Style (reportStyle) which I want to apply to
any new text that I import.

However, I just can't manage to achieve this. I think the main point I
am probably missing is to extend the range to the end of the text that
I have just inserted, then apply the style. I suspect all I am doing is
apply a style to a bookmark.

Any suggestions ?
Have you tried sticking a couple of myRange.Select statements in there,
and stepping through the code, to see where the range really is at the
critical points?

As I recall, using InsertFile does not, indeed, place the text you're
insering INTO the range, but either before or after it. If this is the
case, it would probably make sense to set a second range that's certain
to be at the other end of the insertion. (Set xRange = myRange.Duplicate,
then move the Start or End points, as appropriate).

Then, you can set the Start or End point of the first range to that of
the second range in order to encompass all the text that was inserted.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
S

sylvian stone

Thanks for your help,

That has seemed to sort out the problem.

Thanks.
SS.
 

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