Lattis2003 Posted August 30, 2009 Share Posted August 30, 2009 I am trying to export Lotus Notes names.nsf address book to a csv file. All data is written correctly to the csv file. I get this error on several of the objects if the field is blank on some of the address book entries: C:\TestLotusNotes.au3 (59) : ==> Object referenced outside a "With" statement.: $Title = $Addr_Doc.GetFirstItem("Title" ).Text $Title = $Addr_Doc.GetFirstItem("Title" )^ ERROR If i populate all the address's with Title information i do not get the error. expandcollapse popupLocal $Addr_Doc, $FirstName, $MiddleName, $LastName, $Fullname, $Title, $Suffix, $CompanyName, $Department Local $JobTitle, $Comment, $BusinessPhone, $BusinessFax, $BusinessStreet, $BusinessCity, $BusinessState, $BusinessZip, $BusinessCountry Local $HomePhone, $HomeFax, $MobilePhone, $HomeStreet, $HomeCity, $HomeState, $HomeZip, $HomeCountry Local $EmailAddress, $Birthday, $Anniversary, $WebPage, $Manager, $Assistant, $Spouse, $Children, $Location, $Pager, $BusinessPager $Session = ObjCreate("Notes.NotesSession") $Addr_db = $Session.GetDatabase("", "Names.nsf") $Addr_view = $Addr_db.GetView("People") $Addr_Doc = $Addr_view.GetFirstDocument $File = "C:\AddressBook.csv" FileWrite($File, "First Name" & _ "," & "Middle Name" & _ "," & "Last Name" & _ "," & "Full name" & _ "," & "Title" & _ "," & "Suffix" & _ "," & "Company" & _ "," & "Department" & _ "," & "JobTitle" & _ "," & "Comment" & _ "," & "Business Phone" & _ "," & "Business Fax" & _ "," & "Business Street" & _ "," & "Business City" & _ "," & "Business State" & _ "," & "Business Postal Code" & _ "," & "Business Country" & _ "," & "Home Phone" & _ "," & "Home Fax" & _ "," & "Mobile Phone" & _ "," & "Home Street" & _ "," & "Home City" & _ "," & "Home State" & _ "," & "Home Postal Code" & _ "," & "Home Country" & _ "," & "E-Mail Address" & _ "," & "Birthday" & _ "," & "Anniversary" & _ "," & "Web Page" & _ "," & "Manager's Name" & _ "," & "Assistant's Name" & _ "," & "Spouse" & _ "," & "Children" & _ "," & "Business Pager" & _ "," & "Personal Pager" & _ "," & "Location" & @CRLF) While 1 If Not IsObj($Addr_Doc) Then ExitLoop $FirstName = $Addr_Doc.GetFirstItem("FirstName" ).Text $MiddleName = $Addr_Doc.GetFirstItem("MiddleInitial" ).Text $LastName = $Addr_Doc.GetFirstItem("LastName" ).Text $Fullname = $Addr_Doc.GetFirstItem("FullName" ).Text $Title = $Addr_Doc.GetFirstItem("Title" ).Text $Suffix = $Addr_Doc.GetFirstItem("Suffix" ).Text $CompanyName = $Addr_Doc.GetFirstItem("CompanyName" ).Text $Department = $Addr_Doc.GetFirstItem("Department" ).Text $JobTitle = $Addr_Doc.GetFirstItem("JobTitle" ).Text $Comment = $Addr_Doc.GetFirstItem("Comment" ).Text $BusinessPhone = $Addr_Doc.GetFirstItem("OfficePhoneNumber" ).Text $HomePhone = $Addr_Doc.GetFirstItem("PhoneNumber" ).Text $MobilePhone = $Addr_Doc.GetFirstItem("CellPhoneNumber" ).Text $BusinessFax = $Addr_Doc.GetFirstItem("OfficeFaxPhoneNumber" ).Text $HomeFax = $Addr_Doc.GetFirstItem("HomeFaxPhoneNumber" ).Text $BusinessCity = $Addr_Doc.GetFirstItem("OfficeCity" ).Text $BusinessStreet = $Addr_Doc.GetFirstItem("OfficeStreetAddress" ).Text $BusinessState = $Addr_Doc.GetFirstItem("OfficeState" ).Text $BusinessZip = $Addr_Doc.GetFirstItem("OfficeZip" ).Text $BusinessCountry = $Addr_Doc.GetFirstItem("OfficeCountry" ).Text $HomeCity = $Addr_Doc.GetFirstItem("City" ).Text $HomeStreet = $Addr_Doc.GetFirstItem("StreetAddress" ).Text $HomeState = $Addr_Doc.GetFirstItem("State" ).Text $HomeZip = $Addr_Doc.GetFirstItem("Zip" ).Text $HomeCountry = $Addr_Doc.GetFirstItem("Country" ).Text $EmailAddress = $Addr_Doc.GetFirstItem("InternetAddress" ).Text $Birthday = $Addr_Doc.GetFirstItem("Birthday" ).Text $Anniversary = $Addr_Doc.GetFirstItem("Anniversary" ).Text $WebPage = $Addr_Doc.GetFirstItem("WebSite" ).Text $Manager = $Addr_Doc.GetFirstItem("Manager" ).Text $Assistant = $Addr_Doc.GetFirstItem("Assistant" ).Text $Spouse = $Addr_Doc.GetFirstItem("Spouse" ).Text $Children = $Addr_Doc.GetFirstItem("Children" ).Text $BusinessPager = $Addr_Doc.GetFirstItem("PhoneNumber_6" ).Text $Pager = $Addr_Doc.GetFirstItem("PersPager" ).Text $Location = $Addr_Doc.GetFirstItem("Location" ).Text MsgBox(0, "", "FirstName: " & $FirstName & @CRLF & _ "MiddleName: " & $MiddleName & @CRLF & _ "LastName: " & $LastName & @CRLF & _ "FullName: " & $Fullname & @CRLF & _ "Title: " & $Title & @CRLF & _ "Suffix: " & $Suffix & @CRLF & _ "CompanyName: " & $CompanyName & @CRLF & _ "Department: " & $Department & @CRLF & _ "Job Title: " & $JobTitle & @CRLF & _ "Comment: " & $Comment & @CRLF & _ "Business Phone: " & $BusinessPhone & @CRLF & _ "Business Fax: " & $BusinessFax & @CRLF & _ "Business Street: " & $BusinessStreet & @CRLF & _ "Business City: " & $BusinessCity & @CRLF & _ "Business State: " & $BusinessState & @CRLF & _ "Business Postal Code: " & $BusinessZip & @CRLF & _ "Business Country: " & $BusinessCountry & @CRLF & _ "Home Phone: " & $HomePhone & @CRLF & _ "Home Fax: " & $HomeFax & @CRLF & _ "Mobile Phone: " & $MobilePhone & @CRLF & _ "Home Street: " & $HomeStreet & @CRLF & _ "Home City: " & $HomeCity & @CRLF & _ "Home State: " & $HomeState & @CRLF & _ "Home Postal Code: " & $HomeZip & @CRLF & _ "Home Country: " & $HomeCountry & @CRLF & _ "E-Mail Address: " & $EmailAddress & @CRLF & _ "Birthday: " & $Birthday & @CRLF & _ "Anniversary: " & $Anniversary & @CRLF & _ "Webpage: " & $WebPage & @CRLF & _ "Manager's Name: " & $Manager & @CRLF & _ "Assistant's Name: " & $Assistant & @CRLF & _ "Spouse: " & $Spouse & @CRLF & _ "Children: " & $Children & @CRLF & _ "Business Pager: " & $BusinessPager & @CRLF & _ "Pager: " & $Pager & @CRLF & _ "Location: " & $Location) FileWrite($File, $FirstName & _ "," & $MiddleName & _ "," & $LastName & _ "," & $Fullname & _ "," & $Title & _ "," & $Suffix & _ "," & $CompanyName & _ "," & $Department & _ "," & $JobTitle & _ "," & $Comment & _ "," & $BusinessPhone & _ "," & $BusinessFax & _ "," & $BusinessStreet & _ "," & $BusinessCity & _ "," & $BusinessState & _ "," & $BusinessZip & _ "," & $BusinessCountry & _ "," & $HomePhone & _ "," & $HomeFax & _ "," & $MobilePhone & _ "," & $HomeStreet & _ "," & $HomeCity & _ "," & $HomeState & _ "," & $HomeZip & _ "," & $HomeCountry & _ "," & $EmailAddress & _ "," & $Birthday & _ "," & $Anniversary & _ "," & $WebPage & _ "," & $Manager & _ "," & $Assistant & _ "," & $Spouse & _ "," & $Children & _ "," & $BusinessPager & _ "," & $Pager & _ "," & $Location & @CRLF) $Addr_Doc = $Addr_view.GetnextDocument($Addr_Doc) WEnd Link to comment Share on other sites More sharing options...
Danny35d Posted August 31, 2009 Share Posted August 31, 2009 Add COM Error Handling to you script. Scroll half way the link. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Lattis2003 Posted August 31, 2009 Author Share Posted August 31, 2009 Add COM Error Handling to you script. Scroll half way the link.Danny35d,I do have com error handling i just did not post it in the example. I should have stated that. It never throws a com error. I can force it to throw a com error so i know that's working.I am testing the address book with 6 entries. All the data gets written correctly with the error. If i manually look at the default datafrom say "Title: it is "" If i select any entry like Mr. and then change it back to none the value changes to "0" and the errors disappear for this field.Same thing for "Suffix". It also gets the same error on "PhoneNumber" but if i add an entry and remove it the value goes back to the default "" and the errors disappear for "PhoneNumber". If i populate all fields with data the error never occurs.If i test it with one entry and the fields are null the error never occurs. It only happens when it loops the next document.I have tried setting the values in the script to "" before it loops to the next document with no luck.I have tried to suppress the error with no luck.I am going to put this into a vbscript today and test it.ThanksLattis Link to comment Share on other sites More sharing options...
Lattis2003 Posted September 1, 2009 Author Share Posted September 1, 2009 Turns out to be a corrupt entry in the names.nsf. Nothing worng with the script. My fault for over looking a few things. Lattis Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now