Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Upstate NY, New York, USA
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Autotext entries lose styles/numbering (Word 97/VBA)

    I posted this question under the Word board, but thought I'd better post it under VB too. I am inserting autotext entries via a VBA routine in Word. The paragraphs contain the appropriate styles and numbering (Heading 1, Heading 2), and when I defined the autotext entries, I was sure to include the paragraph marker. However, when the document assembles at the end of the routine, the entire document is body text style. When inserted manually, the autotext entries are formatted fine. I don't want to have to insert each paragraph separately via VB and then apply the appropriate style. Any suggestions from the experts?

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autotext entries lose styles/numbering (Word 97/VBA)

    Post your code, specifically the line that inserts the autotext. I'm wondering if you are using the Richtext:= true argument.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    Upstate NY, New York, USA
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autotext entries lose styles/numbering (Word 97/VBA)

    Hi Kev!

    Here's a bit of it:

    'Yes Director - Yes Plan
    If frmAuditLtrStandard.CheckBox8 = True Then
    If frmAuditLtrStandard.CheckBox1 = True Then
    ActiveDocument.Variables.Add Name:="AttorneyName", Value:=frmAuditLtrStandard.TextBox31.Text
    ActiveDocument.Variables.Add Name:="FiscalYear", Value:=frmAuditLtrStandard.TextBox30.Text
    If frmAuditLtrStandard.OptionButton1 = True Then
    ActiveDocument.Variables.Add Name:="AttorneyCapacity", Value:="Trustee"
    ElseIf frmAuditLtrStandard.OptionButton2 = True Then
    ActiveDocument.Variables.Add Name:="AttorneyCapacity", Value:="Director"
    End If
    ActiveDocument.AttachedTemplate.AutoTextEntries("O ption11").Insert _
    Where:=Selection.Range
    'Yes Director - No Plan
    ElseIf frmAuditLtrStandard.CheckBox8 = True Then
    If frmAuditLtrStandard.CheckBox1 = False Then
    ActiveDocument.Variables.Add Name:="AttorneyName", Value:=frmAuditLtrStandard.TextBox31.Text
    ActiveDocument.Variables.Add Name:="FiscalYear", Value:=frmAuditLtrStandard.TextBox30.Text
    If frmAuditLtrStandard.OptionButton1 = True Then
    ActiveDocument.Variables.Add Name:="AttorneyCapacity", Value:="Trustee"
    ElseIf frmAuditLtrStandard.OptionButton2 = True Then
    ActiveDocument.Variables.Add Name:="AttorneyCapacity", Value:="Director"
    End If
    ActiveDocument.AttachedTemplate.AutoTextEntries("O ption11A").Insert _
    Where:=Selection.Range
    End If
    End If
    End If

    This is SO VEXING!!!! Thanks for any insight you can give me.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autotext entries lose styles/numbering (Word 97/VBA)

    Add Richtext:=true

    to this line:

    ActiveDocument.AttachedTemplate.AutoTextEntries("O ption11A").Insert _
    Where:=Selection.Range, Richtext:=True


    From the Help:
    "RichText Optional Variant. True to insert the AutoText entry with its original formatting."
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Upstate NY, New York, USA
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autotext entries lose styles/numbering (Word 97/VBA)

    You are WONDERFUL Kevin! Thank you! That works. I looked under Help but richtext is not listed... I'm only using VBA -- why wouldn't it be listed in help though? Thanks again - you're a lifesaver! <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

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