PC Review


Reply
Thread Tools Rate Thread

CreateObject - start Access from Excel

 
 
Piers 2k
Guest
Posts: n/a
 
      6th Oct 2006
Hi folks,

Am trying to start an Access database from VBA, but it closes itself when
the code finishes. I simply don't want this to happen. The following code
works fine if I change the Access into Word (see the comment):

Sub StartApp()

Dim OtherApp As Object

' Set OtherApp = CreateObject("Word.Application")
Set OtherApp = CreateObject("Access.Application")

OtherApp.Visible = True

End Sub

Any help please?
TIA,

Piers


 
Reply With Quote
 
 
 
 
Robert Bruce
Guest
Posts: n/a
 
      6th Oct 2006
Roedd <<Piers 2k>> wedi ysgrifennu:

> Hi folks,
>
> Am trying to start an Access database from VBA, but it closes itself
> when the code finishes. I simply don't want this to happen. The
> following code works fine if I change the Access into Word (see the
> comment):
>
> Sub StartApp()
>
> Dim OtherApp As Object
>
> ' Set OtherApp = CreateObject("Word.Application")
> Set OtherApp = CreateObject("Access.Application")
>
> OtherApp.Visible = True
>
> End Sub
>
> Any help please?
> TIA,
>
> Piers


Move the declaration (Dim statement) outside the sub procedure. The variable
is going out of scope when the procedure exits and this kills the
application it refers to.


--
Rob


 
Reply With Quote
 
Piers 2k
Guest
Posts: n/a
 
      6th Oct 2006
Arrrggghhh! Don't you hate it when it's obvious!

Thanks - much appreciated!


 
Reply With Quote
 
Jean-Yves
Guest
Posts: n/a
 
      6th Oct 2006
It does not close if you open a file
Regards
JY
"Piers 2k" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Arrrggghhh! Don't you hate it when it's obvious!
>
> Thanks - much appreciated!
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Can't start multiple instances of Excel with CreateObject Jon Peltier Microsoft Excel Programming 0 3rd Dec 2006 05:34 PM
RE: Can't start multiple instances of Excel with CreateObject =?Utf-8?B?Sm9obiBCdW5keQ==?= Microsoft Excel Programming 0 3rd Dec 2006 12:24 PM
CreateObject internet access NickP Microsoft VB .NET 10 19th Apr 2006 09:10 AM
Excel CreateObject on server Dennis Redfield Microsoft Excel Programming 9 15th Jul 2005 10:09 PM
CreateObject("Excel.Application") -> Access denied Luca Microsoft Excel Programming 0 6th Feb 2004 01:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:44 AM.