Manage Learn to apply best practices and optimize your operations.

Quick And Easy Labels

This script does a simple export of selected documents from a personal address
book to a pipe "|" delimited text file. I use a Microsoft Access database to
link to the text file. Using a query to pull business address or personal
address if the business address is not available. Use a label wizard in Access
to create labels for the specific Avery label you want. This tip is more of a
way to use Access for reporting from Notes Databases. If the text file is
linked rather than imported. Every time the agent runs to create the file,
Access will use the most recent data, so you don't have to import the data. To
print labels from the address book: 1. Select documents, 2. Run "Generate
Labels File" agent, 3. Open the Access database and run the Label report. I
was not able to attach the Access file. Send me an email @
DaveMcGrew@Yahoo.com and I will email you the NSF that has the Access table
attached.
Sub Initialize

Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument

Dim fieldlist List As String

fileNum1% = Freefile ()
fileName1$ = "c:\labels.TXT"
Open fileName1$ For Output As fileNum1%

fileNum2% = Freefile ()
fileName2$ = "c:\labelcol.TXT"
Open fileName2$ For Output As fileNum2%

fieldlist("Title") = ""
fieldlist("FirstName") = ""
fieldlist("Middle Initial") = ""
fieldlist("LastName") = ""
fieldlist("Suffix") = ""
fieldlist("JobTitle") = ""
fieldlist("CompanyName") = ""
fieldlist("HomeAddress1") = ""
fieldlist("HomeAddress2") = ""
fieldlist("City") = ""
fieldlist("State") = ""
fieldlist("Zip") = ""
fieldlist("Country") = ""
fieldlist("OfficeStreetAddress1") = ""
fieldlist("OfficeStreetAddress2") = ""
fieldlist("OfficeCity") = ""
fieldlist("OfficeState") = ""
fieldlist("OfficeZip") = ""
fieldlist("OfficeCountry") = ""
fieldlist("Custom3") = ""
fieldlist("Custom4") = ""

'- Initialize Variables
startTime! = Timer()
count% = 0
counter% = 0

Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
While Not doc Is Nothing
addr$ = ""
'This prints a list of all the fields. You can copy all lines and then paste
into the table design in Access to keep from having to manually type in all the
fields for the first time setup of the linked table.
Forall x In fieldlist
If count% = 0 Then
Print #fileNum2%, Listtag(x)
End If
If Instr(Listtag(x), "Address") > 0 Then
value = doc.GetItemValue( Left(Listtag(x), Len(Listtag(x))
-1))
temp = value
lineno% = Cint(Right(Listtag(x), 1))
value(0) = fPullLine(temp(0), lineno%)
Else
value = doc.GetItemValue(Listtag(x))
End If

addr$ = addr$ + value(0) + "|"
End Forall

Print #fileNum1%, addr$

count% = count% + 1

Set doc = dc.GetNextDocument(doc)
' get the next document and do it again.
Wend


Close fileNum1%
Close fileNum2%


End Sub

' when passed a multiline string (contains HEX 0D0A), will return the specified
line. Extra 0D0A characters will through the text file out of whack. This
assures that there will not be extraneous line feeds in the file.

Function fPullLine( Original As String, lineno As Integer) As String

Redim vLines(0) As String
vString$ =
Original ' set Target$
equal to the Original string
crlf$ = Chr(13)+Chr(10)
strpos% = Instr(vString$, crlf$) '
get position of substring in the main string
count% = 0
While strpos% > 0
Redim Preserve vLines(count%) As String
strpos% =
strpos%-1 ' get
the position prior to the found string
lenOrig% =
Len(vString$) ' get
length of entire string
vLines(count%) = Left(vString$, strpos%
) ' extract chars from the left of the
string up to the beginning of the substring
vString$ = Right(vString$, lenOrig% - strpos%-2) ' extract chars
from the right of the string up to the end of the substring (len of string -
position of CRLF - 2 for the CRLF&LTW
This was last published in November 2000

Dig Deeper on Domino Resources - Part 5

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchExchange

SearchContentManagement

Close