• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4635
  • Last Modified:

Adjust line spacing in Word document

Greetings Experts,

I have an application that creates a word document.  I need to be able to set the default line spacing for this document from double to single.  I know the proper technique, however I am getting an error.

error message:
"The measurement must be between 0.7 pt and 1584 pt."

occurs on line:
.ParagraphFormat.LineSpacing = Word.WdLineSpacing.wdLineSpaceSingle

Any help you can lend in this matter would be appreciated.  Thank you in advance.
Dim WordApp As New Word.Application
Dim doc As Word.Document = WordApp.Documents.Add()
With WordApp.Selection
            .ParagraphFormat.LineSpacing = Word.WdLineSpacing.wdLineSpaceSingle
            .Font.Size = 12
            .Font.Bold = CInt(True)
            .ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
            .TypeText("CREDIT REFERENCE REPLY")
            .ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
            .Font.Bold = CInt(False)
            .Font.Size = 10
            .TypeText("Date:" & vbTab & vbTab & "05/22/09" & vbCrLf)
            .TypeText("From:" & vbTab & vbTab & "Credit Department" & vbCrLf)
            .TypeText("To:" & vbTab & vbTab & "Fax Number" & vbCrLf)
            .TypeText("Attn:" & vbTab & vbTab & "Contact Name" & vbCrLf)
            .TypeText("Subject:" & vbTab & vbTab & "Credit Reference Response")
            Dim srCreditLegal As StreamReader
            Dim strCreditLegal As String
            srCreditLegal = New StreamReader("C:\Credit Legal.txt")
                strCreditLegal = srCreditLegal.ReadToEnd()
                .Font.Size = 7
            Catch ex As Exception
                MessageBox.Show("Error reading Credit Legal file" & vbCrLf & ex.Message)
            End Try
End With
End Sub

Open in new window

  • 2
  • 2
1 Solution
instead of
 .ParagraphFormat.LineSpacing = Word.WdLineSpacing.wdLineSpaceSingle

 .ParagraphFormat.LineSpacing = 1
gwosgoodIT MgrAuthor Commented:
Hehe, I tried that, lets just say it did not turn out well.  I needed a magnifying glass to read the text.

I guess I need to know what the pt equivalent of single spacing is.  Any idea on how to find that?
I dnt kno much abt it and I was searching in net and I found it.
use this before the line spacing and try

.LineSpacingRule = wdLineSpaceExactly

Check this link
gwosgoodIT MgrAuthor Commented:
Ahah, a combination of the two is my answer

.LineSpacingRule = Word.WdLineSpacing.wdLineSpaceSingle

works perfectly!

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!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now