Solved

Run-time error '91' Object variable or with block variable not set in outlook 2003

Posted on 2006-07-20
9
498 Views
Last Modified: 2008-01-09
I am trying to run a macro in outlook 2003 and I am getting the error above, any help would be appreciated.

the macro is shown below:

Sub type1()
    Dim strMessage, olkItem, olkReply, olkInbox, olkNewFolder
    strMessage = "Thank you for forwarding your CV which we have received. We look forward to working with you."

    Set olkItem = Application.ActiveInspector.CurrentItem
    Set olkReply = olkItem.Reply
    With olkReply
        .Subject = "Confirmation of receipt"
        .Body = strMessage
        .Send
    End With
    On Error Resume Next
    Set olkInbox = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    Set olkNewFolder = olkInbox.Folders.Add("Type 1")
    Set olkNewFolder = olkInbox.Folders("Type 1")
    If olkNewFolder Is Nothing Then
    Set olkNewFolder = olkInbox.Folders.Add("Type 1")
    End If
    Set olkForward = olkItem.Forward
    olkForward.Recipients.Add "email@email.com"
    olkForward.Send
    olkItem.Move olkNewFolder
    On Error GoTo 0
End Sub
0
Comment
Question by:proltdman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 8

Expert Comment

by:hiteshgupta1
ID: 17145195
hi
read this article
it will help u in solving the problem

http://support.microsoft.com/default.aspx/kb/250309
0
 
LVL 8

Expert Comment

by:hiteshgupta1
ID: 17145197
let us know if u have any problem
0
 

Author Comment

by:proltdman
ID: 17145279
Thanks but sorry this solution did not help me resolve the issue, anyone else out there with another idea?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Accepted Solution

by:
Suat Ozgur earned 250 total points
ID: 17145353
Hi,

Try using :

    Set olkItem = Application.ActiveExplorer.Selection.Item(1)

instead in line 5 in your code.

Suat
0
 

Author Comment

by:proltdman
ID: 17145423
Thanks smozgur, your solution did the trick!
0
 
LVL 17

Expert Comment

by:Suat Ozgur
ID: 17145438
Glad to hear that!

Thanks for the A grade.
Suat
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17153389
Just to explain a bit about why this problem cropped up, the original line of code

    Set olkItem = Application.ActiveInspector.CurrentItem

gets the open item.  You were getting an error because there was no open item.  The line of code

    Set olkItem = Application.ActiveExplorer.Selection.Item(1)

that smozgur had you use in its place gets the selected item instead of the open item.  
0
 

Author Comment

by:proltdman
ID: 17153398
thanks for the explanation BDF!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17157289
:-)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question