VBA - change textformat after a linefeed

  • Thread starter Thread starter nidec
  • Start date Start date
N

nidec

Dear members,
I have a problem. I created an access application that exports
a query into a new xls file. Then is start formating the cells.
I have two fields StatementE (English) and StatementD (Dutch) for each
record.
Those two statements are to be placed into one cell.
The first line normal (StatementE) and the Second Line (StatementD) in
Italic.

I already succeeded in placing both statement in one cell.

ObjXl.Cells.Range("A1") = Objxl.Cells.Range("B1") & _
chr(10) & Objxl.Cells.Range("C1")

But i can not format the second line to Italic. Already tried by
setting the source cell "C1" in Italic. But it only gives me the value
and not the Italic.

Best regards,
Nidec
 
Nidec,

You need to access the Characters Object (look it up in VBA Help). This
enables you to format a part of a range. You know where the characters start
from, because it would be the length of B1 + 2.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Mr Phillips,

Many thanks for your help.

BeginInt = len(Objxl.Cells.Range("B1")) + 2
LenInt = Len(Objxl.Cells.Range("C1"))

Objxl.Cells.Range("A1").Characters(BeginInt, LenInt).Font.Italic
True

It works perfectly now
 
Back
Top