'-------------------------------------------------------------------
' Word Basic macro to print to Seiko Label Printer using SLPVB.DLL.
' Delete the SLProPostNet line if you don't want a barcode.
'
' Copyright  1995 Somar Software, All Rights Reserved
' Send problem reports and comments to 72202.2574@compuserve.com
'
'--------------------------------------------------------------------
Declare Sub SLPVBStartDoc Lib "SLPVB.DLL"(szPrinterName As String)
Declare Sub SLPVBSetFont Lib "SLPVB.DLL"(szFontName As String, \
	PtSize As Long, fBold As Long, fItalic As Long)
Declare Sub SLPVBTextOut Lib "SLPVB.DLL"(szText As String)
Declare Sub SLPVBPostNet Lib "SLPVB.DLL"(szText As String)
Declare Sub SLPVBLineOut Lib "SLPVB.DLL"(LineLenTwips As Long)
Declare Sub SLPVBEndDoc Lib "SLPVB.DLL"()

Sub Main
	Dim s$, t$, c$, i, j, nRows
	Dim lines$(10)
	s$ = Selection$()
	nRows = 0
	i = 1
	j = 1
	For i = 1 To Len(s$)
		If Asc(Mid$(s$, i, 1)) < 32 Then
			t$ = LTrim$(Mid$(s$, j, i - j))
			If Len(t$) > 0 Then
				lines$(nRows) = t$
				nRows = nRows + 1
				If nRows = 10 Then Goto maxrows
			EndIf
			j = i + 1
		EndIf
	Next i

maxrows:

	If nRows = 0 Then Goto exit

	SLPVBStartDoc "Seiko" ' this name is case-sensitive

	SLPVBSetFont "Arial", 12, 1, 1
	SLPVBTextOut "Somar Software"
	SLPVBSetFont "Arial", 10, 0, 0
	SLPVBTextOut "1 Scott Circle, NW Suite 816"
	SLPVBTextOut "Washington, DC 20036"
	SLPVBLineOut 4320
	SLPVBSetFont "Times New Roman", 6, 0, 0
	SLPVBTextOut " "
	t$ = "     "
	SLPVBSetFont "Times New Roman", 12, 0, 0
	For i = 0 To nRows - 1
		SLPVBTextOut t$ + lines$(i)		
	Next i
	For i = 1 To 6 - nRows
		SLPVBTextOut " "
	Next i

	s$ = RTrim$(lines$(nRows - 1))
	For i = Len(s$) To 1 Step - 1
		c$ = Mid$(s$, i, 1)
		If c$ = " " Then
			s$ = Mid$(s$, i + 1)
			If Len(s$) > 0 Then
				SLPVBPostNet t$ + s$
				Goto enddoc
			EndIf
		ElseIf (c$ <> "-") And (c$ < "0" Or c$ > "9") Then
			Goto enddoc
		EndIf
	Next i

enddoc:

	SLPVBEndDoc

exit:
	
End Sub
