Results 1 to 5 of 5

Thread: Office 2003, VB6 problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Location
    South Africa
    Posts
    26

    Office 2003, VB6 problem

    Hi

    I am busy making an app that searches through all items in my inbox and saves certain types of attachments to a specified folder.

    However when i run my program i get the an error
    "Automation error, The specified module could not be found"

    Under the references i have "Microsoft Outlook 11.0 Object library" ticked as well as a couple others.

    the error occurs when the following line is executed

    VB Code:
    1. Set oOutlook = New Outlook.Application

    the part of code is below

    VB Code:
    1. Dim oOutlook As Outlook.Application
    2. Dim oNs As Outlook.NameSpace
    3. Dim oFldr As Outlook.MAPIFolder
    4. Dim oMessage As Object
    5. Dim sPathName As String
    6. Dim oAttachment As Outlook.Attachment
    7. Dim iCtr As Integer
    8. Dim iAttachCnt As Integer
    9.  
    10. If txtPath = "" Then
    11.  MsgBox "Enter a path to save attachments to!", vbExclamation + vbOKOnly, "Path problem"
    12. Else
    13.  sPathName = txtPath.Text
    14.  If Right(sPathName, 1) <> "\" Then sPathName = sPathName & "\"
    15.    If Dir(sPathName, vbDirectory) = "" Then FileSystem.MkDir (sPathName)
    16.  
    17.    [COLOR=Red] Set oOutlook = New Outlook.Application[/COLOR]
    18.     Set oNs = oOutlook.GetNamespace("MAPI")
    19.     Set oFldr = oNs.GetDefaultFolder(olFolderInbox)

    Any help would be greatly appreciated.

    Thanks
    Nath

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Location
    South Africa
    Posts
    26

    Re: Office 2003, VB6 problem

    Hi

    Just a little something else i discovered, if outlook 2003 is open when i run the program and i change

    VB Code:
    1. Set oOutlook = New Outlook.Application

    to

    VB Code:
    1. Set oOutlook = Outlook.Application

    then it works. so there seems to be a problem with the "new" but i still dont know how to correct it....

    Nath

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Office 2003, VB6 problem

    If your adding a reference to Outlook then the Set oOutlook = New Outlook.Application will work. If your not setting a reference to Outlook then use Set oOutlook = CreateObject("Outlook.Application") and that will create the instance. The reason why Set oOutlook = Outlook.Application works if Outlook is running is because its already created. If its not running then it will error.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Location
    South Africa
    Posts
    26

    Re: Office 2003, VB6 problem

    Hi

    I have tried what you said and i still get the "Automation error, The specified module could not be found" error.

    It does this if i have the reference included and use
    VB Code:
    1. Set oOutlook = New Outlook.Application

    it also happens if i use no reference and
    VB Code:
    1. Set oOutlook = CreateObject("Outlook.Application")

    could this possibly be a problem with my outlook installation??

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Office 2003, VB6 problem

    Yes, it could be. Try a Detect and Repair from Outlooks help menu and maybe an Office Update.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width