dswaff,
There is nothing wrong with what Word is doing with your NotePad data which, by the way, contains no tabs. You should note too, that a NotePad file doesn't use either a monospaced font or a proportional one. In fact, a NotePad file contains no font information at all. Your monospaced font display in NotePad is just that - a display setting, not a format of the text itself.
In Word, characters in a given monospaced font are all given exactly the same width, in proportion to the point size. Simply expanding all the widths by 0.176389mm as you have tried to do has no effect whatsoever on whether you'll get a fixed width. All that will do is add a constant amount to every character's width, regardless of whether the underlying character uses a monospaced font or a proportional one. They'll have exactly the same width differences after applying the adjustment as they did before. If you want Word to display your data monospaced, format the content in Word with a monospaced font.
Your 'bad Word' example doesn't even use a monospaced font - it's using a proportional one (TNR), so it's a particularly poor example of Word supposedly not displaying a monospaced font correctly.
Notwithstanding any of the above, what can mess things up with the
appearance of monospaced fonts in Word, though, is applying a Style that uses:
• paragraph justification and having content that wraps to the next line.
• text distribution
If the text file also contains tabs, instead of being spaced-out as yours is, the tab-stops in Word can result in a different tabbed appearance.
Your Function could be simplified and its efficiency improved with:
Code:
Function ConvertTxtToWord(TxtFileFullName As String)
Dim objWord As Object, objDoc As Object
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = False
Set objDoc = .Documents.Open(TxtFileFullName)
With objDoc
With .PageSetup
.Orientation = 1
.TopMargin = 1
.BottomMargin = 1
.LeftMargin = 0
.RightMargin = 0
End With
With .Range
.Font.Name = "Courier New"
.Font.Size = "8"
.ParagraphFormat.LineSpacing = "2"
.ParagraphFormat.Alignment = "0"
End With
.SaveAs Replace(.FullName, ".txt", ".doc")
.Close
End With
.Quit
End With
Set objWord = Nothing: Set objDoc = Nothing
End Function
Cheers
Paul Edstein
[MS MVP - Word]