Results 1 to 5 of 5

Thread: [RESOLVED] Question about references

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Posts
    69

    Resolved [RESOLVED] Question about references

    Well I can use iTunes Type Library to play itunes music, but if they don't have itunes installed, it will give an error with something like missing reference right?

    How do I make it so that it just greys the option in the menu( so basically don't set the reference ) if iTunes isn't installed.

  2. #2
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: Question about references

    You can try to create an iTunes object and error trap for error 420 - cant create object. Also, you could try reading the registry and see if its installed but that takes more code then a n error trap.
    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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Posts
    69

    Thanks for the quick reply!

    Ok I sorta copied the code. It uses WithEvents. If that doesn't change anything would this be suitable code?

    Private Sub Form_Load()
    On Error Goto ObjectTrap
    Dim WithEvents iTunes As iTunesApp
    Set iTunes = New iTunesApp
    Exit Sub
    ObjectTrap:
    If Err.Number = 420 Then
    itunesMenuItem.Enabled = False
    Else
    'normal error handle, send error to via email
    End If
    End Sub


    But that only declares it within the Sub Form_Load. How do I do it in the Declarations section?

    (PS I posted a new topic called SORRY, can someone delete that, I was trying to reply to this, and pressed the wrong button )

  4. #4
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: Question about references

    It would be more ike this. (I had a type o with the error number its 429).
    VB Code:
    1. Public WithEvents iTunes As iTunesApp
    2. Private Sub Form_Load()
    3.     On Error Goto ObjectTrap
    4.  
    5.     Set iTunes = New iTunesApp
    6.     Exit Sub
    7. ObjectTrap:
    8.     If Err.Number = 429 Then
    9.         itunesMenuItem.Enabled = False
    10.     Else
    11.         'normal error handle, send error to via email
    12.     End If
    13. End Sub
    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Posts
    69

    Re: Question about references

    Thanks!

    I will see if that works.


    Edit:
    Tested on a machine without itunes, and it works perfectly. Thanks alot for the code, and the quick response.
    Last edited by solinent; Apr 23rd, 2006 at 07:42 PM.

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