none
Drawing lines on my document RRS feed

  • Question

  • Ok I have figured out how to draw lines on the document I'm working on, however I can't seem to get them to stay where I would like.  For example for the first template I'm making I need it to add 3 lines to each page so that the test in the document would look something like this

    Test Line, Text Line, Test Line, Text Line
    Test Line, Text Line
    -----------------------------------------------
    Test Line, Text Line
    -----------------------------------------------
    Test Line, Text Line
    Test Line, Text Line
    Test Line, Text Line
    Test Line, Text Line
    etc...
    ----------------------------------------------
    Some other text
    end of page

    right now I have the format worked out for the letter and the overlay lines are in the right spot, if I print it out and stack the pages it's where I want it, however when I try to add the lines they are on a page by them selves at the end of the document.

    This is the sub I have to draw the lines:

    Public Sub DrawOverlay(OverlayFile As String, wrdDoc As Word.Document)
        Dim numOfLines As Int16 = 0
        Dim reader As TextReader
        Dim currentLine As String
        Dim line As String()
        Dim intBeginX As Int16
        Dim intEndX As Int16
        Dim intBegY As Int16
        Dim intEndY As Int16
    
        reader = New StreamReader(OverlayFile)
        numOfLines = reader.ReadLine()
        Do
          ' retreive the current line and split it to an array for parsing
          currentLine = reader.ReadLine()
          If currentLine.Length > 1 Then
            line = currentLine.Split(New Char() {" "c})
            ' populate the variables for the line positions
            intBeginX = line(0)
            intBegY = line(1)
            intEndX = line(2)
            intEndY = line(3)
            wrdDoc.Shapes.AddLine(intBeginX, intBegY, intEndX, intEndY).Select()
          End If
    
        Loop Until currentLine = Nothing
    
      End Sub
    

    This info is gathered in the first line of the text file so after the margins are set up (First part of the first line) this sub is called.

    Using VB.net 2010 and word 2000, thanks in advance.

    Wednesday, April 20, 2011 4:14 PM

All replies

  • Hello,

    I'm guessing a little bit now but this might be an Anchor problem. Choose to 'view all' in the document and select your line on the last page. Look where the Anchor is located for that line. A shape must be on the same page as the Achor. If your Anchor is on the last page, as well as the line, you can set the Anchor for the line to a Paragraph Range on the page where you want to line to be.

    I don't know if this is of any help at all, but might help.

    Regards,
    Lars-Eric

    Wednesday, April 20, 2011 6:14 PM
  • Hi temlehdrol,

    I believe the Shapes.Addxxx command inserts a shape formatted as a floating shape. You will probably need to add a command such as this.

    Selection.ShapeRange.WrapFormat.Type = wdWrapNone 'the value 3 is wdWrapNone

    Hope this helps


    Regards
    Thursday, April 21, 2011 4:50 AM
  • I'm seeing that the anchor poisition isn't fixed, so perhaps that could be the problem.  The other problem is the line isn't part of the text file that i'm working with it's part of another file with fixed positioning (basically the text file has to fit wihin the constraints of the overlay file).
    Thursday, April 21, 2011 2:39 PM