none
Run time error 438 RRS feed

  • Question

  • I have the following piece of macro that gives me a run time error. My document is being created through a third party program. It runs if not created through the third party program. It gives me the error at this line:

     

        ActiveDocument.AttachedTemplate.AutoTextEntries("CB").Insert Where:=oRng, RichText:=True

     

    I have my original template located in the following location:

     

    U:\Startup\Imact4.dotm

     

    Is there a way to point to this template to get my AutoTextEntries to work?

     

     

     

    For i = 36 To 38

      Set oRng = ActiveDocument.Bookmarks("CB" & i).Range

      If Me.Controls("Ck" & i).Value = True Then

        ActiveDocument.AttachedTemplate.AutoTextEntries("CB").Insert Where:=oRng, RichText:=True

        oRng.Font.Color = wdColorBlack

        oRng.Font.Size = 14

      Else

        ActiveDocument.AttachedTemplate.AutoTextEntries("UCB").Insert Where:=oRng, RichText:=True

        oRng.Font.Color = wdColorAutomatic

        oRng.Font.Size = 12

      End If

      ActiveDocument.Bookmarks.Add "CB" & i, oRng

    Next i

     

    Thursday, February 3, 2011 10:07 PM

Answers

  • This is what I added and it worked.

    With ActiveDocument
        .UpdateStylesOnOpen = True
        .AttachedTemplate = "U:\STARTUP\Impact4 2010 R5.dotm"
        .XMLSchemaReferences.AutomaticValidation = True
        .XMLSchemaReferences.AllowSaveAsXMLWithoutValidation = False
    End With

    • Marked as answer by fuzzhead58 Saturday, February 5, 2011 1:29 AM
    Saturday, February 5, 2011 1:29 AM
  • ·         Hi fuzzhead58,

    I’m glad to hear you resolve your issue. Thanks for sharing your experiences here, and it will be very beneficial for other community members who have similar questions to see how you have dealt with your issue.

    Have a great day,

    Tom Xu


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by fuzzhead58 Tuesday, September 9, 2014 3:06 PM
    Monday, February 7, 2011 2:34 AM
    Moderator

All replies

  • Are you sure that the document is actually attached to the template with the AutoText entries?

    Does that run-time error give you any descriptive (text) inforamtion besides the error number?


    Cindy Meister, VSTO/Word MVP
    Friday, February 4, 2011 9:01 AM
    Moderator
  • This is what I added and it worked.

    With ActiveDocument
        .UpdateStylesOnOpen = True
        .AttachedTemplate = "U:\STARTUP\Impact4 2010 R5.dotm"
        .XMLSchemaReferences.AutomaticValidation = True
        .XMLSchemaReferences.AllowSaveAsXMLWithoutValidation = False
    End With

    • Marked as answer by fuzzhead58 Saturday, February 5, 2011 1:29 AM
    Saturday, February 5, 2011 1:29 AM
  • ·         Hi fuzzhead58,

    I’m glad to hear you resolve your issue. Thanks for sharing your experiences here, and it will be very beneficial for other community members who have similar questions to see how you have dealt with your issue.

    Have a great day,

    Tom Xu


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by fuzzhead58 Tuesday, September 9, 2014 3:06 PM
    Monday, February 7, 2011 2:34 AM
    Moderator