Enter a new Line in word using Excel VBA

  • Hi,


    I am a newbee to VBA. I want to copt data from excel to Word using VBA. In order to make reading easy I need to seperate the data with a new line. So, how do I enter a new line when in Word using excel VBA?


    thanks in Advance

  • Re: Enter a new Line in word using Excel VBA


    Depends entirely on how you are putting the information into Word. In the absence of any sample code, the standard way to add a new line (paragraph) in Word is to use the TYPEPARAGRAPH method.


    Code
    Selection.TypeParagraph
  • Re: Enter a new Line in word using Excel VBA


    Thanks for the reply Cytop:


    Here is the Code



    Now in the above code where do I use the command that you have mentioned.


    Thanks in Advance

  • Re: Enter a new Line in word using Excel VBA


    Try this.

    Code
    For rowi = 1 To 10
            val1 = Cells(rowi, clmi1).Value
            val2 = Cells(rowi, clmi2).Value
            val3 = Cells(rowi, clmi3).Value
            wdoc.Content.InsertAfter (" value: " & val1 & val2 & val3 & vbNewLine)       
        Next rowi

    Boo!:yikes:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!