#### DECLARATIONS ####
Declare Function W32_NSFDbRename Lib "nnotes.dll" Alias "NSFDbRename" _
(Byval OldDatabase As String, _
Byval NewDatabase As String) As Integer
Declare Function W32_OSLoadString Lib "nnotes.dll" Alias "OSLoadString" _
(Byval hModule As Long, _
Byval StringCode As Integer, _
Byval retBuffer As String, _
Byval BufferLength As Integer) As Integer
#### SCRIPT CODE ####
Sub Initialize
Dim iret As Integer
Dim szError As String * 256
Dim ErrorString As String
Dim StrLen As Integer
Dim nnServer As NotesName
Dim oldDatabase As String
Dim newDatabase As String
Set nnServer = New NotesName("My Server/My Org")
oldDatabase = "mailoldmailfile.nsf"
newDatabase = "mailnewmailfile.nsf"
'if a server is not specified, then only parse the database information to the API function,
'not the server if a server is specified, then parse both the server and database to
'the API function
If nnServer.Canonical = "" Then
iret = W32_NSFDbRename(oldDatabase, newDatabase)
Else
iret = W32_NSFDbRename(nnServer.Canonical & "!!" & oldDatabase, nnServer.Canonical & "!!" & newDatabase)
End If
'If an error occurs, then convert and display the error number and error message
If iret <> 0 Then
ErrorString = ""
szError = String$(256, 0)
StrLen = W32_OSLoadString(0, iret, szError, 255)
If Strlen <> 0 Then ErrorString = Left$(szError, StrLen)
Msgbox "Error " & iret & " (" & ErrorString & ")",,"Lotus Notes Error"
End If
End Sub