ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   loading another application from excel vba (https://www.excelbanter.com/excel-programming/403784-loading-another-application-excel-vba.html)

badazizi

loading another application from excel vba
 
I want to be able to launch another vba-enabled application from an Excel
command button. I have the code and references to do this already. However,
I need to figure out how I can programmatically check to see if the computer
has the application installed before I try to dim an object for the
application. I need to do this because the Excel file would be used by
people that don't have the application as well as those that do. I want to
give the users that don't a meaningful error if they don't have it. How
would I go about doing that?

Chip Pearson

loading another application from excel vba
 
If you cannot be sure that a machine has that program and typelib installed,
you cannot (or at least should not) declare any variables of types that are
defined in the program. For example,

' Instead of
Dim V As YourProg.SomeType
' Use
Dim V As Object

If you use the first line of code and the machine doesn't have the program
installed, the compiler will complain that SomeType is an unknown type,
probably before any of your code in the workbook executes.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"badazizi" wrote in message
...
I want to be able to launch another vba-enabled application from an Excel
command button. I have the code and references to do this already.
However,
I need to figure out how I can programmatically check to see if the
computer
has the application installed before I try to dim an object for the
application. I need to do this because the Excel file would be used by
people that don't have the application as well as those that do. I want
to
give the users that don't a meaningful error if they don't have it. How
would I go about doing that?



Bernie Deitrick

loading another application from excel vba
 
Have you tried capturing an error when setting the object?

Dim oApp As Object
On Error GoTo NotAvailable
Set oApp = CreateObject("NameOfApp.application") 'As appropriate
GoTo Available
NotAvailable:
MsgBox "Application was NOT available on this machine"
Exit Sub
Available:
MsgBox "Application IS available on this machine"
'Othe code here


It would be done like this for Word:

Dim oWord As Object
On Error GoTo NotAvailable
Set oWord = CreateObject("word.application")
GoTo Available
NotAvailable:
MsgBox "Word was NOT available on this machine"
Exit Sub
Available:
MsgBox "Word IS available on this machine"

HTH,
Bernie
MS Excel MVP


"badazizi" wrote in message
...
I want to be able to launch another vba-enabled application from an Excel
command button. I have the code and references to do this already. However,
I need to figure out how I can programmatically check to see if the computer
has the application installed before I try to dim an object for the
application. I need to do this because the Excel file would be used by
people that don't have the application as well as those that do. I want to
give the users that don't a meaningful error if they don't have it. How
would I go about doing that?





All times are GMT +1. The time now is 03:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com