Results 1 to 11 of 11

Thread: [RESOLVED] Word Interop - Add paragraph and InsertFile

Threaded View

  1. #1

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Resolved [RESOLVED] Word Interop - Add paragraph and InsertFile

    Really I am trying, but I am beginning to believe that I hate Interop.

    I am trying to add a paragraph to the end of a document I have open.

    Code:
            Dim newPara As Word.Paragraph = docAChap.Paragraphs.Add
            With newPara
                .Range.Text = _schn ''The range cannot be deleted error here sometimes
                .Range.Font.Bold = 1
                .Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
            End With
    The range cannot be deleted error only happens sometimes.
    It has to be something simple, like me.

    Someone please tell me there is a way to insert a file without losing the format of the file being inserted.

    Code:
            rng = docAChap.Range(Start:=DirectCast(docAChap.Content.End - 1, Object), End:=DirectCast(docAChap.Content.End, Object))
            rng.Collapse(Word.WdCollapseDirection.wdCollapseEnd)
            rng.InsertFile(FileName:="pathHere".ToString)
    This inserts the file but formatting is gone.

    I know that this looks like a two topic thread, but it is only one, me hatin' on Interop
    Last edited by dbasnett; Mar 23rd, 2016 at 04:06 PM.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width