Excel/Runtime error 91


Hi Gulshan,
First of all thanks a lot for this opportunity

I am working on macro where range of excel is copied and pasted into lotus notes. But I am getting runtime error 91

Code is as below
Sub NewEmailButton_Click()
   Dim NSession As Object
   Dim NDatabase As Object
   Dim NUIWorkSpace As Object
   Dim NDoc As Object
   Dim NUIdoc As Object
   Dim WordApp As Object
   Dim subject As String
   subject = "Ticket raised for Password reset : "
   Debug.Print subject
   Set NSession = CreateObject("Notes.NotesSession")
   Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace")
   Set NDatabase = NSession.GetDatabase("", "")
   If Not NDatabase.IsOpen Then NDatabase.OPENMAIL
   Set NDoc = NDatabase.CreateDocument
       With NDoc
       .SendTo = " "
       .CopyTo = ""
       .subject = subject
       End With
       Set NUIdoc = NUIWorkSpace.EDITDocument(True, NDoc)
   With NUIdoc
       .GotoField ("Body")
       Sheets("Preview & To Lotus").Range("A1:L18").Copy
       Application.CutCopyMode = False
      End With
      Set NSession = Nothing
End Sub

Hi Ganesh,

I'm not able to simulate your issue at my computer.
Looks like you are trying to access another database through this macro.

Can you send me the files you are using (after replacing the data with dummy data) or atleast the exact error message given by excel.

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts




I can answer questions related to the following topics: 1. MS Excel - Creating and Linking Formulae, Running Pivot Tables, Vlookup etc. 2. Macros / VBA - Creating Macros to do specific jobs. Importing / Exporting / Validating Data in excel through Macros.


I've been working on excel for over 10 years and on VBA macros for over 3 years now.

Bachelor of Commerce, Chartered Accountant from The Institute of Chartered Accountants of India

©2016 About.com. All rights reserved.