Results of script to create CSV file

I have the following little script. It works, but when I look at the results in excel, each column has about 7-8 spaces before the data starts. I’ll try to illustrate (quotes/underscores are mine for clarity purposes only) … for column containing state it appears like this “________California” instead of just “California”

I’m always creating a brand new file in excel so I don’t know of any properties there that would affect this. Here is my script:

Sub Initialize

Open "C:\ExportTest\ExpTest40.CSV" For Output As #1



Dim ws As New notesuiworkspace

Set view=ws.currentview.view

Set doc=view.getfirstdocument



Do While Not(doc Is Nothing)

	Print #1, doc.IssueNumber(0),  "," , doc.State(0)

	Set doc=view.getnextdocument(doc)

Loop



Close #1	

End Sub

Subject: Change Print #1 Line

“doc.issuenumber(0)” + “,” + “doc.state(0)” and see if this helps.

Subject: RE: Change Print #1 Line

Tried four different Print statements:

Print #1 “doc.issuenumber(0)” + “,” + “doc.state(0)”

has the literals in each column, not the field values. BUT, the leading spaces are gone.

Print #1 doc.issuenumber(0) + “,” + doc.state(0)

results in “Type mismatch” error

Print #1 doc.issuenumber(0) + doc.state(0) and

Print #1 doc.issuenumber(0) , doc.state(0)

both end up with all data in the first column.

I must be close on the correct combination!!

Subject: RE: Change Print #1 Line

What about:

Print #1 cstr(doc.issuenumber(0)) + “,” + cstr(doc.state(0))

  • not sure if theses are number or text values but try a conversion

Subject: Cstr(doc.issuenumber(0)) + “,” + doc.state(0)

Subject: RE: Change Print #1 Line

That’s because your using the “+” (plus) operator for concatenation. Since this operator implies one of two different operations, it raises a type-mismatch error because one of the fields has a numeric value in it. Use the “&” (ampersand) operator, which is explicitly for concatenation. This avoids the type-checking issue altogether thus making your code a little more bullet-proof.dgg

Subject: Thanks to you all! Summary of solution…

Thanks to you all!

The Cstr worked with the plus sign, but I can omit the Cstr completely if I use the &. But when I had them separated with a comma only, the leading spaces appeared for some reason. Live and learn!

Thanks again!