Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automation of Powerpoint
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Automation of Powerpoint
Miscellaneous
Thread ID:
00695582
Message ID:
00695582
Views:
48
Hi All,

Im am using OLE automation of powerpoint to parse ppt files into a modified HTML format. I cannot use the default export to HTML included in powerpoint.

When parsing the information, I need to generate HTML that takes bold, italic, and underline into account (IOW generates appropriate HTML tags < B >, etc). The only way that I have found to generate the HTML is to go character by character through the ranges of text evaluating bold, italic and underline (see the code below).

The approach works, but the problem is that iterating character by character (in addition to checking the properties of each character several times) using automation is REALLY REALLY REALLY REALLY REALLY slow. (Did I mention it was slow? < g >.)

Does anyone have a faster approach?

TIA,
Rick
#DEFINE msoTrue  -1
#DEFINE msoFalse  0

oTextRange = oApplication.ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange

lnCharacters = oTextRange.Characters.Count

llBold   = .F.
llItalic = .F.
llBold   = .F.
lcHTML   = ""

FOR lnChar = 1 TO lnCharacters
    oChar = oTextRange.Characters(lnChar)

    llCurrentCharIsBold   = (oChar.Font.Bold      = msoTrue)
    llCurrentCharIsItalic = (oChar.Font.Italic    = msoTrue)
    llCurrentCharIsUnderline = (oChar.Font.Underline = msoTrue)

    IF !llBold AND llCurrentCharIsBold
       lcHTML = lcHTML + "<B>"
    ENDIF

    IF !llItalic AND llCurrentCharIsItalic
       lcHTML = lcHTML + "<I>"
    ENDIF

    IF !llUnderline AND llCurrentCharIsUnderline
       lcHTML = lcHTML + "<U>"
    ENDIF

    *-- check for end tags in reverse order

    IF llUnderline AND !llCurrentCharIsUnderline
       lcHTML = lcHTML + "</U>"
    ENDIF

    IF llItalic AND !llCurrentCharIsItalic
       lcHTML = lcHTML + "</I>"
    ENDIF

    IF llBold AND !llCurrentCharIsBold
       lcHTML = lcHTML + "</B>"
    ENDIF

    *-- Insert character into HTML
    lcHTML = lcHTML + oChar.Text

ENDFOR

*-- end any tags left open

IF llUnderline 
   lcHTML = lcHTML + "</U>"
ENDIF

IF !llItalic 
   lcHTML = lcHTML + "</I>"
ENDIF

IF !llBold
   lcHTML = lcHTML + "</B>"
ENDIF
Rick
Rick Hodder
MCP Visual Foxpro
C#, VB.NET Developer
Independent Consultant
www.RickHodder.com
MyBlog
Next
Reply
Map
View

Click here to load this message in the networking platform