Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

start excel from vba

Status
Not open for further replies.

stibbetts

Technical User
May 6, 2004
64
US
would anyone happen to know off the top of their head how to start the actual excel program through code?
 
Do a keyword search in this forum for 'start excel'.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
stibbetts,

VBA differs from VB in that VBA MUST be run from WITHIN an MS OFfice Application, like Word, Excel, Powerpoint, Access, Outlook.

So if you are asking that from "scratch" you want to start Excel via VBA, the answer is, "No!"

However, if you have an MS Office application other tnan Excel running, then from THAT application you can start Excel using the CreateObject method.

Which is it?

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
stibbetts
If you bear Skip's comments in mind this will open an instance of Excel from (I'd guess) any application that supports VB/VBA. What you must do though is create a reference to the Excel Object library in your host application.

Please don't shoot me down if, for whatever reason, I'm wrong in my "any app" assumption as I have no idea about things like Crystal Reports or Visio or anything like that!!!

What it doesn't do, however, is check to see if Excel is already open. I feel sure I've seen some code that does that but can't find it - maybe I imagined it!

Code:
Dim oXLapp As Object
Set oXLapp = New Excel.Application
oXLapp.Visible = True
'do stuff
oXLapp.Quit
Set oXLapp = Nothing

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
is check to see if Excel is already open
The basic idea is to check if the GetObject method raise an error or not.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
loomah,
thank you very much it works wonderfully
 

You could use VB Script

Paste this into notepad and save with a vbs extension.

When you run it it will open Excel.

Dim MyObj
Set MyObj=CreateObject("WScript.Shell")
MyObj.Run "Excel.exe"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top