[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do I check for existence of Powerpoint and Excel from VB app

Posted on 2004-08-30
8
Medium Priority
?
158 Views
Last Modified: 2010-04-23
I have a vb .net application that creates powerpoint and excel presentations.  I works fine, unless the user doesn't have powerpoint and excel installed on their computers.  How do I check for that so that I can issue a warning to the user?

Thanks!
0
Comment
Question by:spmcmorrow
[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
8 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 11931488
One way would be to check the listing of programs that appear in the "Add/Remove Programs" listing you see in the control panel.  This is done by enumerating the "Software\Microsoft\Windows\CurrentVersion\Uninstall" key under the LocalMachine area.  The "DisplayName" value is the installed application.

On my system there is only one entry for the whole office suite, "Microsoft Office XP Professional".  I'm not sure how it looks for other versions of Office.

Below is an application that populates a ListBox with all installed applications on the system.  I'm not sure if Administrator rights are required to use this approach.

Regards,

Idle_Mind

Imports Microsoft.Win32

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.ListBox1 = New System.Windows.Forms.ListBox
        Me.SuspendLayout()
        '
        'ListBox1
        '
        Me.ListBox1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.ListBox1.Location = New System.Drawing.Point(8, 8)
        Me.ListBox1.Name = "ListBox1"
        Me.ListBox1.Size = New System.Drawing.Size(288, 160)
        Me.ListBox1.TabIndex = 0
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(304, 182)
        Me.Controls.Add(Me.ListBox1)
        Me.Name = "Form1"
        Me.Text = "Add/Remove Program Listing"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall")
            Dim sk As String
            Dim appKey As RegistryKey
            Dim displayNameValue As Object
            Dim displayName As String
            ListBox1.Sorted = True
            ListBox1.BeginUpdate()
            If Not (rk Is Nothing) Then
                For Each sk In rk.GetSubKeyNames
                    appKey = rk.OpenSubKey(sk)
                    displayNameValue = appKey.GetValue("DisplayName")
                    If Not (displayNameValue Is Nothing) Then
                        ListBox1.Items.Add(CType(displayNameValue, String))
                    End If
                Next
            End If
            ListBox1.EndUpdate()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Error Accessing Registry")
        End Try
    End Sub

End Class
0
 
LVL 8

Accepted Solution

by:
wguerram earned 500 total points
ID: 11937332
Try this:

If you get an error it means the activeX does not exist:        

        Dim x As Object
        Try
            x = CreateObject("PowerPoint.Application")
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            x = Nothing
        End Try

0
 
LVL 8

Expert Comment

by:wguerram
ID: 11937335
The same for excel

 Dim x As Object
        Try
            x = CreateObject("Excel.Application")
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            x = Nothing
        End Try
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 11942293
I like the solution that wguerram has shown, since registry keys are different depending on what version of Excel and PowerPoint that the user has installed.  Generic solutions are the best.

Bob
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 11942502
I agree...wguerram's method will be much cleaner.  This is why I usually preface my posts with "One way would be to..." instead of "The best way would be to..."

=)
Idle_Mind
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11942525
That's true, but the "one way" could be the "best way" for you *GRIN*.  It's all in the eye of the beholder.

Bob
0
 

Author Comment

by:spmcmorrow
ID: 11943011
Should I install active x with my application, or just put out an error message to the user.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11943035
It is against Micro$oft's license agreement to install it if they don't have the application installed.  Therefore, you should put up an error message.

Bob
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

649 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