Hi, I wanted to change the font in a dynamically created word document, I am using Visual C++ and MFC, I am having problems with it, it's the first time i have used a COM, and have managed to cobble together a document from the Microsoft Online Help, but changing the font is eluding me.
Code:
Selection oSel;
_Font oFont = oSel.GetFont();
oFont.SetName("Tahoma");
oFont.SetSize(16);
oSel.SetFont(oFont);
oSel = oApp.GetSelection();
oSel.TypeText("Jobname: ");
AddFieldAtSelection("jobname");
oSel = oApp.GetSelection();
oSel.TypeParagraph();
oSel.TypeText("Job No: ");
AddFieldAtSelection("jobno");
oSel = oApp.GetSelection();
oSel.TypeParagraph();
oSel.TypeText("From: ");
AddFieldAtSelection("start");
oSel.TypeText(" ");
oSel = oApp.GetSelection();
oSel.TypeText("To: ");
AddFieldAtSelection("end");
oSel.ReleaseDispatch();
that is the snippet of code concerning the font and field editing, am I wrong in trying to change the font before typing anything.
The word document can be created without the fint code in there, but the font code produces an "Invalid Parameter" fault.
Thanks in advance.