Subject: Code: Refresh docids from Excel
Here is your excel macro.
Private Sub Excel2Notes_WriteButton_Click()
Dim Msg
On Error GoTo ErrorHandler
Dim Style, Title, Help, Ctxt, Response, MyString
Msg = “You are about to update records in Notes! Do you want to continue ?” ’ Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ’ Define buttons.
Title = “WARNING BE CAREFUL” ’ Define title.
Help = “” ’ Define Help file.
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then
' No Action, continue with Sub
Else
MsgBox ("Aborted. Action has been cancelled")
Exit Sub
End If
Set objWorksheet = Application.ActiveWindow.ActiveSheet
strNotesServer = objWorksheet.Range(“H3”).Value 'put your server name in cell H3
strNotesDatabase = objWorksheet.Range(“J3”).Value 'put your notes database filepath in cell J3
Set objNotes = CreateObject(“Lotus.NotesSession”)
objNotes.Initialize
Set objDB = objNotes.GetDatabase(strNotesServer, strNotesDatabase)
Set objView = objDB.GetView(“(Excel2Notes)”)
intRow = 6 'what row to begin with
Do
strWkSht_Key = objWorksheet.Range(“A” + Trim(Str(intRow))).Value
If Len(strWkSht_Email) < 2 Then
If Val(strWkSht_Email) = 0 Then
Exit Do
End If
End If
Set objDoc = objView.GetDocumentByKey(strWkSht_Key)
If Not objDoc Is Nothing Then
Call objDoc.ComputeWithForm(False, False)
Call objDoc.Save(True, False)
intRow = intRow + 1
Loop
tmp = MsgBox(Prompt, vbOKOnly, CStr(intRow - 6) + " Records Updated")
ErrorHandler:
If Err.Number = 13 Then
strWkSht_Key = Trim(Str(objWorksheet.Range(“A” + Trim(Str(intRow))).Value))
Resume Next
End If
If Err.Number <> 0 Then
Msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
Resume Next
End If
End Sub