Re: Help for a novice

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I don't see any code yet to instantiate colInsp. If you want the whole routine to run automatically, you need code in the Application_Startup event handler in ThisOutlookSession to handle that.

As I said in my earlier post, if you check the value of the message's Sent property and it equals False, then you know you have a reply, forward, or new message, one that you don't want to process.

Other issues:

Outlook VBA includes an intrinsic Application object, so you don't need to use CreateObject to create another one.

Also, you said "users." Outlook VBA code is not meant to be redistributed. Ultimately, you should be thinking about building this functionality into an OUtlook COM add-in. See http://www.outlookcode.com/d/comaddins.htm

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"SuperSlueth" <np121@xxxxxxxxxxx> wrote in message news:sikmv15s31aq622aj03eiamiab4chii3qq@xxxxxxxxxx
The code that you suggested, when does it run ....
I mean does the user have to do something or does this code run when a
new mail comes in.

The users here don't want the attachments for every mail to open. only
when the user opens it to read.

Quite often we get unwanted or duplicate mails with attachements ...
the user just wants to delete these without the attachments opening

Thanks for you continued help
I've included my code for your information



This is the code so far

Code in "ThisOutlookSession"


Dim WithEvents colInsp As Outlook.Inspectors
Public WithEvents myItem As Outlook.MailItem

Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)

Call Att_Open
End Sub


Code in Module ....
It runs fine when an email is opened to read, but also runs when the
user selects Reply. ReplyAll forward or New .... which i need to stop

Sub Att_Open()

Dim myolApp As Outlook.Application
Dim myinspector As Outlook.Inspector
Set myolApp = CreateObject("Outlook.Application")
Set myinspector = myolApp.ActiveInspector
Dim I As Integer


If TypeName(myinspector) = "Nothing" Then
Exit Sub

ElseIf Application.ActiveInspector.CurrentItem.Attachments.Count =
0 Then
MsgBox "No Attachments"

ElseIf Application.ActiveInspector.CurrentItem.Attachments.Count >
0 Then
I = Application.ActiveInspector.CurrentItem.Attachments.Count
MsgBox I

End If


End Sub




On Tue, 21 Feb 2006 11:53:32 -0500, "Sue Mosher [MVP-Outlook]"
<suemvp@xxxxxxxxxxxxxxx> wrote:

Take a look at http://www.outlookcode.com/codedetail.aspx?id=1140. Check the message's Sent property equals False, then you know you have a reply, forward, or new message.

Note that this has nothing to do with custom forms.
.



Relevant Pages

  • Re: Problem with filling in Attachments
    ... Author of Configuring Microsoft Outlook 2003 ... I get the following error when I fill in the attachments: Error # 446: No ... Dim olInsp As Object ... Dim olAtt As Object ...
    (microsoft.public.outlook.program_vba)
  • Re: Problem with filling in Attachments
    ... Author of Configuring Microsoft Outlook 2003 ... I get the following error when I fill in the attachments: Error # 446: No ... Dim olInsp As Object ... Dim olAtt As Object ...
    (microsoft.public.outlook.program_vba)
  • RE: Automated macro shut down
    ... Try Picture Attachments Wizard for Outlook: ... date and attaches the saved email attachments to the appointment, ... Dim WithEvents TargetFolderItems As Items 'Event handler for Lab ... Date received string ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: Automated macro shut down
    ... Try Picture Attachments Wizard for Outlook:http://www.collaborativeinnovations.ca ... date and attaches the saved email attachments to the appointment, ... Dim i As Integer 'counter to help make unique subjects ... Date received string ...
    (microsoft.public.office.developer.outlook.vba)
  • Automated macro shut down
    ... date and attaches the saved email attachments to the appointment, ... Dim WithEvents TargetFolderItems As Items 'Event handler for Lab ... Date received string ...
    (microsoft.public.office.developer.outlook.vba)