Find & Replace problem with UserID field in local address books - via button - PART 2

sjef_bosman updated my code and it works great - thanks Sjef.  But now I need it to check if the USERID field is in h:\notes\data before changing it to y:\notes\data, otherwise my laptop users will be in big trouble!

 Sub Click(Source As Button)
      Dim session As New notessession
      Dim s As String
      
    ' For The Current User in The Current Session, Get All The NABs
      Forall books In session.addressbooks                        
          'Check If The Current NAB is Private or Public
          'If The NAB Is Private, Than It Should Be Your Personal NAB          
            If books.isprivateaddressbook Then                      
               'Verify if The NAB is Open, If Not, Open it
                  If Not(Books.isopen) Then
                        Call Books.open("",books.filename)
               'Now Get All The Documents in The Location View  
                        Set view = books.getview("Locations")          
                        Set doc = view.getfirstdocument                    
               'For All The Documents in The View
                        While Not (doc Is Nothing)                                
                     ' Get The userid Field and Modify it to)
                              s= doc.GetItemValue("Userid")(0)
                              s= Strrightback(s, "\")
                              Call doc.replaceitemvalue ("userid","Y:\NOTES\DATA\" + s)        
                    'Save Document
                              Call doc.save (True,True)                                      
                    'Get Next document
                              Set doc = view.getnextdocument(doc)                  
                        Wend
                  End If
            End If  
      End Forall
End Sub
IdltdAsked:
Who is Participating?
 
Sjef BosmanGroupware ConsultantCommented:
Sorry, I assumed all users had H:.... in their user-id. How 'bout this change:

Sub Click(Source As Button)
     Dim session As New notessession
     Dim s As String
     
    ' For The Current User in The Current Session, Get All The NABs
     Forall books In session.addressbooks                        
          'Check If The Current NAB is Private or Public
          'If The NAB Is Private, Than It Should Be Your Personal NAB          
          If books.isprivateaddressbook Then                      
               'Verify if The NAB is Open, If Not, Open it
               If Not(Books.isopen) Then
                    Call Books.open("",books.filename)
               'Now Get All The Documents in The Location View  
                    Set view = books.getview("Locations")          
                    Set doc = view.getfirstdocument                    
               'For All The Documents in The View
                    While Not (doc Is Nothing)                                
                     ' Get The userid Field and Modify it to)
                         s= doc.GetItemValue("Userid")(0)
                         ' if the current user-id starts with H:
                         If Ucase(Left(s, 2))= "H:" Then
                             s= Strrightback(s, "\")
                             Call doc.replaceitemvalue ("userid","Y:\NOTES\DATA\" + s)        
                        'Save Document
                             Call doc.save (True,True)                                      
                          End If
                    'Get Next document
                         Set doc = view.getnextdocument(doc)                  
                    Wend
               End If
          End If  
     End Forall
End Sub
0
 
IdltdAuthor Commented:
WOW, your good.  Thanks for all your help.
0
 
Sjef BosmanGroupware ConsultantCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.