Goofy word automation

I wrote a word automation using vb.net. This application formats ascii file to word doc with font size as 8 and font name Courier New. It runs perfectly fine here in UK on Server 2000, all versions of word. It also runs on Server 2003 in UK it formats document with correct font size and font name but here is the problem:
 when document is viewed it displays in double line,while paragraph format shows Singleline. I am completly lost.
 
Thnx in advance.
-kushpaw
kushpawAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

computerg33kCommented:
could u post some code?
0
computerg33kCommented:
   Private Sub CreateMailMergeDataFile()
        Dim wrdDataDoc As Word.Document

        Dim iCount As Integer
        ' Create a data source at C:\DataDoc.doc containing the field data.
        wrdDoc.MailMerge.CreateDataSource(Name:="C:\DataDoc.doc", _
              HeaderRecord:="1")
        ' Open the file to insert data.
        wrdDataDoc = wrdApp.Documents.Open("C:\DataDoc.doc")
        For iCount = 1 To 0
            wrdDataDoc.Tables.Item(1).Rows.Add()
        Next iCount
        ' Save and close the file.
        wrdDataDoc.Save()
        wrdDataDoc.ActiveWindow.Close()
    End Sub



                                        CreateMailMergeDataFile()

                                        '    ' Create an instance of Word  and make it visible.
                                        wrdApp = CType(CreateObject("Word.Application"), Word.Application)
                                        wrdApp.Visible = True

                                        ' Add a new document.
                                        wrdDoc = wrdApp.Documents.Add()
                                        wrdDoc.Select()

                                        wrdSelection = wrdApp.Selection()
                                        wrdMailMerge = wrdDoc.MailMerge()

                                        wrdSelection.PageSetup.LeftMargin = 65
                                        wrdSelection.PageSetup.RightMargin = 30
                                        wrdSelection.PageSetup.TopMargin = 50
                                        wrdSelection.PageSetup.BottomMargin = 50



this is how i initate word
0
kushpawAuthor Commented:

Here is my code:

      Dim doc As Word.DocumentClass
        Dim appclass As Word.ApplicationClass
        'open a new instance of word
        appclass = New Word.ApplicationClass()
        'open up the word document
        appclass.Visible = False
        doc = appclass.Documents.Open(SourceFile)
        doc.ShowGrammaticalErrors = False
        doc.ShowSpellingErrors = False
        appclass.Selection.Delete(Word.WdUnits.wdCharacter, 3)
        appclass.Selection.WholeStory()

      ' misbehaving line of code on Server 2003
        appclass.Selection.Paragraphs.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle
        'appclass.Selection.Paragraphs.LineSpacing = ""

        Dim rng As Word.Range = doc.Range(0, doc.Characters.Count)
        With rng
            .Font.Size = 8
            .Font.Name = "Courier New"
        End With

        With doc.PageSetup
            .LineNumbering.Active = False
            .Orientation = Word.WdOrientation.wdOrientLandscape
            .RightMargin = 72        '1" = 72 points
            .LeftMargin = 72
            .TopMargin = 36
            .BottomMargin = 36
            .PageHeight = 612       'for landscape orientatation,
            .PageWidth = 792        ' height and width is 11 x 8.5
        End With

        doc.SaveAs(DestFile + ".doc", 0)
        doc.Close()
        appclass.Quit()
        doc = Nothing
        appclass = Nothing
        GC.Collect()
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

computerg33kCommented:
well..what happens when that line of code is just taken out?
0
kushpawAuthor Commented:
Oops! I meant to say "it runs perfectly fine here in US(not UK) on Server 2000, all versions of word" in my original question.

My original code that runs on server 2000 here in US has only following lines of code for page format and font settings,

appclass.Selection.Font.Size = 8
appclass.Selection.Font.Name = "Courier New"
With doc.PageSetup
            .LineNumbering.Active = False
            .Orientation = Word.WdOrientation.wdOrientLandscape
end with

If I take away the code such as
            .RightMargin = 72        '1" = 72 points
            .LeftMargin = 72
            .TopMargin = 36
            .BottomMargin = 36
            .PageHeight = 612       'for landscape orientatation,
            .PageWidth = 792    
or
          appclass.Selection.Paragraphs.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle

then page is formatted weirdly, and every paragraph is double spaced.  I believe because UK has different Page Setting then us therefore I had to set all properties explicitly but WHY WOULD THE PROGRAM IGNORE LINESPACING RULE . This one line is holding up this project.

Thnx

0
computerg33kCommented:
if u take out

appclass.Selection.Paragraphs.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle

how does this affect the page?
0
computerg33kCommented:
if that doesn't give u the desired results set
appclass.Selection.Paragraphs.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle
to
appclass.Selection.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle
0
kushpawAuthor Commented:
Thanks computerg33k but it did not work.
It seems like for every paragraph mark it find in the document, it adds an extra. I have tried clearformattiong but it did not work either.

0
computerg33kCommented:
check your vbcr documents (this puts in a paragraph) and check your insertparagraphbefore's and insertparagraphafter's (if one paragraph has a before and the one paragraph before this paragraph has an after--that will insert two enters)
0
kushpawAuthor Commented:
Some one at work found out that, Inserting fake paragraph mark is known bug. Search on google.group for "FAKE PARAGRAPH MARK IN WORD"

Here is the code that solved my problem.

With appclass.Selection.Find
            .Text = "^13^p"
            .Replacement.Text = "^p"
            .Forward = True
            .Wrap = Word.WdFindWrap.wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
End With

 
0
moduloCommented:
PAQed with points refunded (125)

modulo
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.