Negative Font Size

  • Thread starter Thread starter Pferril
  • Start date Start date
P

Pferril

HI all, Im developing an application to export PowerPoint 2003 Content to
Word 2003 (Dont ask why), and it works pretty well, but im facing a problem
here, for some reason (Sometimes) i get a font size negative. Here´s some
code


objSlide =
(Microsoft.Office.Interop.PowerPoint._Slide)objPres.Slides._Index(i);
CantShapes = objSlide.Shapes.Count;

for (int j = 1; j <= CantShapes; j++)
{
if (objSlide.Shapes[j].HasTextFrame ==
MsoTriState.msoTrue)
{
objTextRng =
objSlide.Shapes[j].TextFrame.TextRange;

ShapeText = objTextRng.Text + "\r\n";
if (ChkBxEstilo.Checked == true)
{
Microsoft.Office.Interop.PowerPoint.Font
fuente = objSlide.Shapes[j].TextFrame.TextRange.Font;

WordApp.Selection.Font.Name = fuente.Name;
WordApp.Selection.Font.Size = fuente.Size;
WordApp.Selection.Font.Bold =
(int)fuente.Bold;
WordApp.Selection.Font.Italic =
(int)fuente.Italic;
WordApp.Selection.Font.Color =
(Microsoft.Office.Interop.Word.WdColor)fuente.Color.RGB;

}
WordApp.Selection.TypeText(ShapeText);
}

}


As you see, i put the text shape text in the ShapeText and pass it to
WordApp.Selection. The problem comes when i want to format the text. Im
having problemsd with the Font.Size part, sometimes (with particular files) i
get a -2.0 font size. The weird part its that if i open the PPt file and
check that shape font, it is correct (36--28--20 all non negative) and only
happends with some files, not with all of them.
Does anyone has any ideas on this matter?, im kind of stuck here.
Tnks a lot for your time.
 
Quick suggestion... check the default font size in the files where you get a
negative. Ie go to Format/Font and compair the default size which comes up to
the files where it works fine.

I have not look into detail in your code, I just have a hutch.

When PPT copies text, it often does it relative to the deafult font size.
 
Glen tnks a millon for the "lightning" response, i really appreciatte it.
Unfourtunatelly it didnt work, both the files that work and those who doesnt,
both show arial 18 normal as default font.
Any other ideas?

Tnks a millon again for the quick response

Glen (TD DTP) said:
Quick suggestion... check the default font size in the files where you get a
negative. Ie go to Format/Font and compair the default size which comes up to
the files where it works fine.

I have not look into detail in your code, I just have a hutch.

When PPT copies text, it often does it relative to the deafult font size.

--
Glen (TD-DTP)
It''''s cold up here in Toronto...
Sent Vegemite!!!!!


Pferril said:
HI all, Im developing an application to export PowerPoint 2003 Content to
Word 2003 (Dont ask why), and it works pretty well, but im facing a problem
here, for some reason (Sometimes) i get a font size negative. Here´s some
code


objSlide =
(Microsoft.Office.Interop.PowerPoint._Slide)objPres.Slides._Index(i);
CantShapes = objSlide.Shapes.Count;

for (int j = 1; j <= CantShapes; j++)
{
if (objSlide.Shapes[j].HasTextFrame ==
MsoTriState.msoTrue)
{
objTextRng =
objSlide.Shapes[j].TextFrame.TextRange;

ShapeText = objTextRng.Text + "\r\n";
if (ChkBxEstilo.Checked == true)
{
Microsoft.Office.Interop.PowerPoint.Font
fuente = objSlide.Shapes[j].TextFrame.TextRange.Font;

WordApp.Selection.Font.Name = fuente.Name;
WordApp.Selection.Font.Size = fuente.Size;
WordApp.Selection.Font.Bold =
(int)fuente.Bold;
WordApp.Selection.Font.Italic =
(int)fuente.Italic;
WordApp.Selection.Font.Color =
(Microsoft.Office.Interop.Word.WdColor)fuente.Color.RGB;

}
WordApp.Selection.TypeText(ShapeText);
}

}


As you see, i put the text shape text in the ShapeText and pass it to
WordApp.Selection. The problem comes when i want to format the text. Im
having problemsd with the Font.Size part, sometimes (with particular files) i
get a -2.0 font size. The weird part its that if i open the PPt file and
check that shape font, it is correct (36--28--20 all non negative) and only
happends with some files, not with all of them.
Does anyone has any ideas on this matter?, im kind of stuck here.
Tnks a lot for your time.
 
If you step through your macro, does fuente.Size represent the actual font
size or a + / - figure ie 24 point font fuente.Size= +8

??? I think I might be taking shot in the dark here.

--
Glen (TD-DTP)
It''''s cold up here in Toronto...
Sent Vegemite!!!!!


Pferril said:
Glen tnks a millon for the "lightning" response, i really appreciatte it.
Unfourtunatelly it didnt work, both the files that work and those who doesnt,
both show arial 18 normal as default font.
Any other ideas?

Tnks a millon again for the quick response

Glen (TD DTP) said:
Quick suggestion... check the default font size in the files where you get a
negative. Ie go to Format/Font and compair the default size which comes up to
the files where it works fine.

I have not look into detail in your code, I just have a hutch.

When PPT copies text, it often does it relative to the deafult font size.

--
Glen (TD-DTP)
It''''s cold up here in Toronto...
Sent Vegemite!!!!!


Pferril said:
HI all, Im developing an application to export PowerPoint 2003 Content to
Word 2003 (Dont ask why), and it works pretty well, but im facing a problem
here, for some reason (Sometimes) i get a font size negative. Here´s some
code


objSlide =
(Microsoft.Office.Interop.PowerPoint._Slide)objPres.Slides._Index(i);
CantShapes = objSlide.Shapes.Count;

for (int j = 1; j <= CantShapes; j++)
{
if (objSlide.Shapes[j].HasTextFrame ==
MsoTriState.msoTrue)
{
objTextRng =
objSlide.Shapes[j].TextFrame.TextRange;

ShapeText = objTextRng.Text + "\r\n";
if (ChkBxEstilo.Checked == true)
{
Microsoft.Office.Interop.PowerPoint.Font
fuente = objSlide.Shapes[j].TextFrame.TextRange.Font;

WordApp.Selection.Font.Name = fuente.Name;
WordApp.Selection.Font.Size = fuente.Size;
WordApp.Selection.Font.Bold =
(int)fuente.Bold;
WordApp.Selection.Font.Italic =
(int)fuente.Italic;
WordApp.Selection.Font.Color =
(Microsoft.Office.Interop.Word.WdColor)fuente.Color.RGB;

}
WordApp.Selection.TypeText(ShapeText);
}

}


As you see, i put the text shape text in the ShapeText and pass it to
WordApp.Selection. The problem comes when i want to format the text. Im
having problemsd with the Font.Size part, sometimes (with particular files) i
get a -2.0 font size. The weird part its that if i open the PPt file and
check that shape font, it is correct (36--28--20 all non negative) and only
happends with some files, not with all of them.
Does anyone has any ideas on this matter?, im kind of stuck here.
Tnks a lot for your time.
 
Hi again Glen, pardon for the late response. Im not sure of your point here,
if you are asking me if fuente.size value, represents the actual size of the
font, it does. For the files that dont give me an error, if the text has a 36
size font, i get a 36.0 float in the fuente.size. However, on those files
that do give me errors, the font its 36, and i get a -2.0 float.
Please tell me if its that what you ask me. Any more ideas?
Tnks again for your time.
 
Do any of the text boxes on your master slide have a font size of 38? If so
that could be where you are getting your -2.

Another thought, are the text boxes set to resize text to fit object?

I am suprise no one else in making suggestions...
 
Hi again Glen, and tnks a lot for your time (again). Lets see, the fonts size
where i get the error varies from file to file. Sometimes its 36 anothers 18
(Font name segoe), but in the files that do work, there´s also fonts of the
same type (segoe) and sizes (18-36).
If you want i can e-mail yo one of the ppts that gives trouble, or upload it
somewhere.
On the other hand, i realizaed that the power point its
Microsoft.Office.Interop.PowerPoint.Font, and the wordApp font
WordApp.Selection.Font its _Font. Whats the difference between the plain
(PPT)Font and (WRD)_Font ? Can there be some missinterpretation?

Tnks a millon again for your time Glen
 
Tnks a lot Steve, that clarifies everything!. Now i would like to know how
to get the style of a word inside a textframe? Any ideas?

Tnks a lot for your response
 
Back
Top