dcsimg
Results 1 to 2 of 2

Thread: Placing image on new page with word Interops

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2019
    Posts
    25

    Placing image on new page with word Interops

    I am creating a Word doc that will have multiple pages (based on query results). The top of each page requires an image and textbox. My issue is a haven't been able to figure out how to addpicture and textbox to the next page.

    Code:
            While Not oRM.EOF
                oDoc.PageSetup.LeftMargin = oWord.InchesToPoints(0.2)
                oDoc.PageSetup.RightMargin = oWord.InchesToPoints(0.2)
                oDoc.PageSetup.TopMargin = oWord.InchesToPoints(0.2)
                oDoc.PageSetup.BottomMargin = oWord.InchesToPoints(0.2)
    
                oDoc.PageSetup.PageWidth = oWord.InchesToPoints(6.0)
                oDoc.PageSetup.PageHeight = oWord.InchesToPoints(4.0)
    
    
                Shape = oDoc.InlineShapes.AddPicture("C:\FOSL\LIBIMAGE.png", False, True)
                Shape.Width = oWord.InchesToPoints(1)
                Shape.Height = oWord.InchesToPoints(0.97)
    
    
                oDoc.Words.Last.InsertBreak(2)
                oRM.MoveNext()
            end while

    Obviuosly I need to move the cursor to the next page. I've been fighting this one fort several hours. Searched but could not find answer.

  2. #2
    PowerPoster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,303

    Re: Placing image on new page with word Interops

    This is a code snippant where I'm tacking documents after each other.

    Code:
    For Each fi As System.IO.FileInfo In dirInfo.GetFiles("*.docx") '
                   If File.Exists(fi.FullName) Then
                        If Not fileArray.Contains(fi.FullName) Then
                            objWord.Selection.InsertFile(FileName:=fi.FullName, Range:="", ConfirmConversions:=False, Link:=False, Attachment:=False)
                            objWord.Application.Selection.EndKey(wdStory)
                            objWord.Application.Selection.Range.InsertBreak(wdPageBreak)
                            fileArray.Add(fi.FullName)
                        End If
                    End If
                Next
    Here are the declarations:

    Dim wdPageBreak As Object = 7
    Dim wdStory As Object = 6
    Dim wordapp As Word.Application = Nothing
    Dim doc As Word.Document = Nothing
    Dim paragraphs As Word.Paragraphs = Nothing

    Instead of inserting the next document try an image.
    Please remember next time...elections matter!

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width