Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Capturing Character 1 of paragraph (VBA/Word/2003 SP2)

    The following code is intended to find all paragraphs in a document that are styled with one of a set of styles and contain no text. I get a type mismatch on the Asc(oPara) = 13 portion of the If statement. Attempts to cure the problem only indicate that I am ignorant of some basic concept.

    Any guidance will be greatly appreciated.
    <pre>Sub AppHdg2()
    '
    '
    Dim oDoc As Document
    Dim oPara As Paragraph

    Set oDoc = ActiveDocument
    For Each oPara In oDoc.Paragraphs
    If Asc(oPara) = 13 And Left(oPara.Style, 9) = "Heading A" Then
    oPara.Style = "Normal"
    End If
    Next oPara
    Set oDoc = Nothing
    End Sub
    </pre>

    Regards
    Don

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Capturing Character 1 of paragraph (VBA/Word/2003 SP2)

    A Paragraph is not a Range, a Paragraph has a Range, and a Range has Text (which is its default property). So use Asc(oPara.Range) or Asc(oPara.Range.Text) instead of Asc(oPara).

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Capturing Character 1 of paragraph (VBA/Word/2003 SP2)

    Thank you Hans. Oh so obvious once pointed out.
    Regards
    Don

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •