I have a string which I m trying to write into a Word Document. What I want
is to have every character of that string in a different font(different
color, size, underlined or not, bold or not etc etc). I am able to achieve
this when i write every character in different line. However i am not able
to do that for the characters on same line, i,e, I am not able to write
characters of different fonts on the same line. Somehow it needs a "\n" to
change font?
Can someone help me with it?
Thanks in advance,
Vishal
Good luck with the solution.
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
Stew
"Vishal Khandelwal" <vishal_k...@persistent.co.in> wrote in message
news:40ed...@newsgroups.borland.com...
OleVariant Template = EmptyParam;
OleVariant NewTemplate = False;
OleVariant ItemIndex = 1;
try
{
//get input
AnsiString temp2 = "abcdadsdadswerwerwr";
char * buf = temp2.c_str();
try
{
WordApplication->Connect();
}
catch(Exception &exception)
{
Application->ShowException(&exception);
Abort;
}
WordApplication->GetDefaultInterface()->Visible = True;
WordApplication->set_Caption(StringToOleStr("Test Word feature"));
//Create new document
WordApplication->Documents->Add(Template, NewTemplate);
//Assign WordDocument component
WordDocument->ConnectTo(WordApplication->Documents->Item(ItemIndex));
//Turn Spell checking off because it takes a long time if enabled
and slows down Winword
WordApplication->Options->CheckSpellingAsYouType = False;
WordApplication->Options->CheckGrammarAsYouType = False;
for(int i=0; i<temp2.Length(); i++)
{
//Insert data
SetFont(i+1);
WordDocument->Range(EmptyParam,
EmptyParam)->InsertAfter(StringToOleStr(buf[i]));
// if i insert this line i can get characters of different fonts
on different lines
// WordDocument->Range(EmptyParam,
EmptyParam)->InsertAfter(StringToOleStr("\n"));
}
//remove links
WordFont->Disconnect();
WordDocument->Disconnect();
WordApplication->Disconnect();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
WordApplication->Disconnect();
}
Thanks,
Vishal
"BigStew" <big_...@talk21.com> wrote in message
RangePtr r;
_FontPtr f;
WordDocument1->Range(EmptyParam,
EmptyParam)->InsertAfter(WideString(temp2));
for(int i=0; i<temp2.Length(); ++i)
{
r = WordDocument1->Range(OleVariant(i), EmptyParam);
f = r->get_Font();
div_t d = div(i, 2);
f->set_Name(d.rem ? WideString("Arial") : WideString("Comic Sans MS"));
r->set_Font(f);
}
Stew
(BTW, watch the over-quoting)
"Vishal Khandelwal" <vishal_k...@persistent.co.in> wrote in message
news:40ee...@newsgroups.borland.com...
i'll try this out straight away.
Thanks,
Vishal
"BigStew" <Big_...@talk21.com> wrote in message
I still have one problem.. in case i have a string of say 100,000
characters.. then storing it at once and the changinthe font of each
character one by one is a very time consuming task.. it takes really long
time.. more than even 30 mins. whats the workard or m i doing something
wrong.
Thanks,
Vishal.
whats the work ard... m i doing something wrong. hers my code now.
"BigStew" <Big_...@talk21.com> wrote in message
Stew
"Vishal Khandelwal" <vishal_k...@persistent.co.in> wrote in message
news:40f2...@newsgroups.borland.com...
Thanks for ur help,
Vishal
"BigStew" <Big_...@talk21.com> wrote in message
news:40f394cd$1...@newsgroups.borland.com...