Solved

VB.NET, Word, Paragraphs, Borders

Posted on 2004-04-29
2
963 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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