Solved

VB.NET, Word, Paragraphs, Borders

Posted on 2004-04-29
2
943 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
ID: 10960780
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
ID: 10961273
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

22 Experts available now in Live!

Get 1:1 Help Now