Determine DropCap and Column state

J

Jay Heuer

OK, I am now giving up to find this one online...

I am working on a conversion tool to dump Word text straight into a Wiki.
The Wiki does support DropCap and Columns.

I simply do not get how I can test whether a paragraph in Word has a DropCap
enabled or not.

I also do not understand how to parse the Word content into the (sometimes
multiple sections of) columns...

Anybody?
 
J

Jezebel

It seems awful cludgy, but ... A dropcap is actually a frame. If you don't
otherwise use frames, then Paragraph.Range.Frames.Count = 1 tells you that
there's a dropcap. If you do have other kinds of frame in the document,
check the content of the frame: for a dropcap it will be a single character,
the same as Paragraph.Range.Characters(1) -- which is unlikely to be the
case for anything else.

I don't understand your question about sections and columns.
 
J

Jay Heuer

Thanks on the DropCaps, I will try that... I do use frames, so I will go for
your idea of checking the frame contents.

On columns: The Wiki supports columns. How do I know when column formatting
(2 or 3 columns) starts in Word, and when it stops?
 
J

Jezebel

Word's columns are specific to each section:

Activedocument.Sections(n).PageSetup.TextColumns.Count
 
J

Jay Heuer

Thanks for that hint...

Hey, there is a faster way (it seems at least) to determine whether there is
a DropCap. Since I am destroying the document formatting anyway, there is no
need to protect it... so:

Private Sub ConvertDropCap()
Dim opara As Paragraph
Dim oRange As Range
Dim c As Integer

REM Better backwards, there is some weird stuff happening otherwise...
For p = ActiveDocument.Paragraphs.Count To 1 Step -1

Set opara = ActiveDocument.Paragraphs(p)
Set oRange = opara.Range

c = oRange.Frames.Count
If (c > 0) Then
opara.DropCap.Clear
REM Woah... if there was a DropCap, there now is a frame less!
If (c <> oRange.Frames.Count) Then
REM Convert to Wiki formatting
oRange.InsertBefore "{DROPCAP()}"
oRange.InsertAfter "{DROPCAP}"
End If
End If
Next p
End Sub
 
J

Jezebel

That's very clever. It will improve performance very slightly (promably
immeasurably) if you use longs rather than integers. (Integers are included
for backward compatability only -- on a 32 bit system they are actually
longs anyway, with the top 16 bits zeroed out, but the system still error
checks for 16 bit overflow).
 
J

Jean-Guy Marcil

Jay Heuer was telling us:
Jay Heuer nous racontait que :
Thanks for that hint...

Hey, there is a faster way (it seems at least) to determine whether
there is a DropCap. Since I am destroying the document formatting
anyway, there is no need to protect it... so:

In your earlier response you wrote that you did use frames other than for
Drop Caps.
If this is the case, the code you posted will not work in paragraphs that
have regular frames as long as a DropCap, or in paragraph that have frames,
but no DropCap.

I think you will have to check each frame for content as Jezebel suggested.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top