Microsoft KB Archive/212531

= WD2000: Print # Statement Separates Fields with Spaces, Not Tabs =

Article ID: 212531

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q212531





SYMPTOMS
When you use the Print # statement in a Visual Basic for Applications macro with the tab(n) argument to write data to a sequential file, the data is written with spaces separating the text, instead of tabs.



CAUSE
This behavior occurs because the tab(n) argument is used to position the insertion point to an absolute column number, where n is the column number.



RESOLUTION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

212536 OFF2000: How to Run Sample Code from Knowledge Base Articles

To resolve this problem, use the vbTab constant to write a tab character to your output file, as in the following sample macro: Sub MyTestOutputFile

Open "TESTFILE" For Output As #1   ' Open file for output.

' Print text with a tab between items. Print #1, "Zone 1"; vbTab; "Zone 2"; vbTab; "Zone 3"

Close #1

End Sub For more information about the Print # statement, from the Visual Basic Editor, click the Office Assistant, type print, click Search, and then click to view "Print # statement."

