I'm trying to write a small Visual Basic...
Articles and Tips: qna
01 Mar 2003
Q.
I'm trying to write a small Visual Basic application to search and replace the personal address books in GroupWise 6.0.2. We are going to turn on native internet addressing and I need a way to "clean out" the e-mail addresses.
Right now they are like this:
"joe.user@domain.com".SMTP.Headquarters.
As you might guess, I want to strip off the string ".SMTP.Headquarters" from the e-mail address. So basically I want to read through each address book entry, check if <E-Mail Address> contains ".SMTP.Headquarters" and if it does, remove it and rewrite just the e-mail address.
I've already done some work with the Token API and I think I can handle the string parsing. But since I'm so new to this, I usually start out with a sample code snippet that is close to what I'm trying to do. I've copied and pasted ABFIND.VBP and ABFIND.FRM from the example code into files which I've opened in VB.
After saying OK to the upgrade from v4 to v6, I got a couple minor errors, which appear to be MouseIcon and Icon settings on the form that point to icons I don't have. This shouldn't cause any problems as far as I can tell.
Basically, ABFIND works until I type something in the "find" box and hit find. Then it dies on this statement
Set GWFoundAddresses = GWABEntries.Find(txtFilter)
The error I get is:
In: Sub GetFondAddresses() Err.Number: -2147352567 Err.Description: Missing Opening Parenthesis
txtFilter is the name of a text box control on the only form in the project. What I believe the programmer was trying to do is get the "text" property of the txtFilter control, which appears to work when invoked like this. However, with my limited knowledge of Visual Basic, what I thought you had to do was use "txtFilter.text." I tried it this way with the same error. I even tried this line instead:
Set GWFoundAddresses = GWABEntries.Find("greg")
And got the same error. So What I am trying to figure out now is what the heck "GWABEntries.Find" is expecting. I think GWABEntries is a variable based on this line:
Set GWABEntries = GWABooks(cboAddressBooks.ListIndex).AddressBookEntries
I then looked for GWABooks, and found this:
Set GWABooks = GWRootAccount.AddressBooks
And lastly,
Set GWRootAccount = GWApp.Login(txtUserID, txtParameters)
But at this point, with my knowledge of VB and the API documentation, I have no idea where to find the ".find" statement (is it a method?) of whatever GWABEntries really is.
Try as I may, I can't make it work. Any help or pointers would be appreciated.
A.
The ONE LINE in the "ABFIND.VBP" sample code that causes a problem in understanding the use of the API is this:
Set GWFoundAddresses = GWABEntries.Find(txtFilter)
While it turns out there is nothing inherently wrong with this line, when you run this app, it may not be obvious that what the user is expected to type in the "Find" text box (what gets assigned to "txtFilter.text") is this:
(<E-Mail Address> CONTAINS "Smith")
So try rewriting it like this:
Set GWFoundAddresses = GWABEntries.Find("(<E-Mail Address> CONTAINS """ + txtFilter.Text + """)")
While it is true that you couldn't type a First Name or Last Name in the dialog box and expect it to work, by looking at the sample code, it would be very easy to see how to modify it to search for any field you wanted to.
* Originally published in Novell AppNotes
Disclaimer
The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.