[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VB.NET, Word, Paragraphs, Borders

Posted on 2004-04-29
2
Medium Priority
?
985 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
tgannetts earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

649 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