Solved

VB.NET, Word, Paragraphs, Borders

Posted on 2004-04-29
2
941 Views
Last Modified: 2011-10-03
Does anyone know how I can get the following to work?

VB.NET doesn't seem to like to apply borders unless you are dealing with a table although the VB macro editor seems to suggest this is the right way to do this.

        With objWord.Selection

            .TypeText("Summary")

            With .Borders(Word.WdBorderType.wdBorderBottom)
                .LineStyle = objWord.Options.DefaultBorderLineStyle
                .LineWidth = objWord.Options.DefaultBorderLineWidth
                .Color = objWord.Options.DefaultBorderColor
            End With

        End With

VB.NET chokes on trying to pass wdBorderBottom as an index to .Borders

The following does work in Word so I don't get what the difference is when I switch to building a word file in VB.NET

Sub Macro7()
    With Selection.Borders(wdBorderBottom)
        .LineStyle = Options.DefaultBorderLineStyle
        .LineWidth = Options.DefaultBorderLineWidth
        .Color = Options.DefaultBorderColor
    End With
End Sub
0
Comment
Question by:Knomaze
2 Comments
 
LVL 5

Accepted Solution

by:
tgannetts earned 500 total points
Comment Utility
The compiler can't determine with property of the Word.Borders class is the default one.

You need toamend the following line

With .Borders(Word.WdBorderType.wdBorderBottom)

to

With .Borders.Item(Word.WdBorderType.wdBorderBottom)

This should solve your problem.

Tom
0
 

Author Comment

by:Knomaze
Comment Utility
WOO HOO!

Do you realize how many hours I've been trying to find that - nothing seems to reference the differenc on the net anywhere.

It also solves my problem with accessing objWord.ActiveDocument.Styles("Normal").Font

Corrected Form should be:

        objWord.ActiveDocument.Styles.Item("Normal").Font

Thank-you very much :)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now