I'd like to programatically add a page border to a document being created.

The Macro code from Word is

  With Selection.Sections(1)
        With .Borders(wdBorderLeft)
            .LineStyle = wdLineStyleThinThickSmallGap
            .LineWidth = wdLineWidth300pt
            .Color = wdColorAutomatic
        End With
  End With

I can't fathom out how to convert this, if indeed it is possible, the only thing i seem to be able to come up with is some 3rd party add in (spire.doc) but don't have the funds for this.

Anyone with any ideas?

Thanks

Recommended Answers

All 2 Replies

You will need to look into using Word interopt.

Here is an example in C# and VB.Net

Here is an example in C#

A good C# to VB.NET converter can be found here.

Thanks Beginnerdev but that solution is the 3rd party addon I specifically did not want to use as I don't have the funds for long term use of this particular addon (only a free trial).
I am already trying to use the Word.Interop but this particular function is evading me at present.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.