![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
it works fine on my development system, even when I use the access2007 /runtime switch |
|
so can I / should I be able to do this with the access2007 runtime ? |
#3
| |||
| |||
|
|
Unfortunately the runtime environment does not support automation or you creating a new instance of access. In fact to be a little bit more specific here, is what happens is if you launch the access runtime without any file name supplied, then it's simply shuts down. So in your code when you create the access application, it does get created, but then since no file name was supplied when it was opened, then it instantly shuts down. (and in fact when you use automation code, you actually don't have the ability to supply that file name when you create the instance of access) What this means is in a runtime environment, you'll have to use the shell command and shell out with a command line prompt to launch another instance of access, I believe you can then still use GetObject(,"Access.Application") to get at that running instance in your current code. it works fine on my development system, even when I use the access2007 /runtime switch Right, you are starting the current application with the runtime switch, but the creation of the new access application in your code is NOT using the runtime switch. so can I / should I be able to do this with the access2007 runtime ? Actually you can't use that code, but as mentioned you should be able to cobble together something that uses the shell() command. Albert D. Kallal *(Access MVP) Edmonton, Alberta Canada Pleaseno_Spam_kal... (AT) msn (DOT) com |
#4
| |||
| |||
|
|
if I start an MDB with the runtime switch, it's because I want to test in runtime mode all the time, not just some of the time so you may be correct, but spawning a new access object from within a runtime environment should behave the same as as spawing it with the actual runtime Yes, but as the runtime per definition cannot remain open without a |
|
and if I shell out a second copy of access, how can I be sure that GetObject(,"Access.Application") will use the correct copy, I could have a couple of running copies of access ? |
#5
| |||
| |||
|
|
On 31 Jul., 00:24, Roger wrote: if I start an MDB with the runtime switch, it's because I want to test in runtime mode all the time, not just some of the time so you may be correct, but spawning a new access object from within a runtime environment should behave the same as as spawing it with the actual runtime Yes, but as the runtime per definition cannot remain open without a database, this would mean that the IDE must immediatly close when started without a database. But the new instance of access doesn't know that your old instance is running in runtime mode, so they would have had to build in something to imitate this behavior. Probably they didn't think about this point in the first place and if I shell out a second copy of access, how can I be sure that GetObject(,"Access.Application") will use the correct copy, I could have a couple of running copies of access ? There are two more alternatives to "new" (but I don't have the runtime to test them). The first: # Dim objAcc As Access.Application # Set objAcc = CreateObject("Access.Application") # objAcc.OpenCurrentDatabase "C:\YourPath\YourDB.mdb" # ..... # objAcc.Quit # Set objAcc = Nothing I imagine that this version will behave exactly the same way as yours, but I'm just curious. The second: # Dim appACC As Object # Set appACC = GetObject("c:\tar\Mytest.mdb") This one will open or activate only Mytest.mdb, even if there are several other instances of Access open. But yes, it will activate an instance of Mytest.mdb at random if several Mytest.mdb are open. Regards Marco P |
#6
| |||
| |||
|
|
if I start an MDB with the runtime switch, it's because I want to test in runtime mode all the time, not just some of the time so you may be correct, but spawning a new access object from within a runtime environment should behave the same as as spawing it with the actual runtime |
|
and if I shell out a second copy of access, how can I be sure that GetObject(,"Access.Application") will use the correct copy, I could have a couple of running copies of access ? |
#7
| |||
| |||
|
|
Unfortunately the runtime environment does not support automation or you creating a new instance of access. In fact to be a little bit more specific here, is what happens is if you launch the access runtime without any file name supplied, then it's simply shuts down. So in your code when you create the access application, it does get created, but then since no file name was supplied when it was opened, then it instantly shuts down. (and in fact when you use automation code, you actually don't have the ability to supply that file name when you create the instance of access) What this means is in a runtime environment, you'll have to use the shell command and shell out with a command line prompt to launch another instance of access, I believe you can then still use GetObject(,"Access.Application") to get at that running instance in your current code. it works fine on my development system, even when I use the access2007 /runtime switch Right, you are starting the current application with the runtime switch, but the creation of the new access application in your code is NOT using the runtime switch. so can I / should I be able to do this with the access2007 runtime ? Actually you can't use that code, but as mentioned you should be able to cobble together something that uses the shell() command. Albert D. Kallal *(Access MVP) Edmonton, Alberta Canada Pleaseno_Spam_kal... (AT) msn (DOT) com |
#8
| |||
| |||
|
|
On Jul 30, 2:45*pm, "Albert D. Kallal" <PleaseNOOOsPAMmkal... (AT) msn (DOT) com wrote: Unfortunately theruntimeenvironment does not support automation or you creating a new instance of access. In fact to be a little bit more specific here, is what happens is if you launch the accessruntimewithout any file name supplied, then it's simply shuts down. So in your code when you create the access application, it does get created, but then since no file name was supplied when it was opened, then it instantly shuts down. (and in fact when you use automation code, you actually don't have the ability to supply that file name when you create the instance of access) What this means is in aruntimeenvironment, you'll have to use the shell command and shell out with a command line prompt to launch another instance of access, I believe you can then still useGetObject(,"Access.Application") to get at that running instance in your current code. it works fine on my development system, even when I use the access2007 /runtimeswitch Right, you are starting the current application with theruntimeswitch, but the creation of the new access application in your code is NOT using the runtimeswitch. so can I / should I be able to do this with the access2007runtime? Actually you can't use that code, but as mentioned you should be able to cobble together something that uses the shell() command. Albert D. Kallal *(Access MVP) Edmonton, Alberta Canada Pleaseno_Spam_kal... (AT) msn (DOT) com I created this function using the full version, even though the shell command opened db3, thegetObject() call creates a second copy which means, when using theruntime, I have the same problem (can't create activex component) I wonder why the full version isn't detecting that a copy of db3 is already running ? Public Function t3() * * Dim obj As Access.Application * * Dim strCmd As String * * Dim strPath As String * * On Error GoTo ferr * * strPath = "\\dev01\access\development\db3.mdb" * * strCmd = "C:\Program Files (x86)\Microsoft Office\OFFICE12" * * If (Dir(strCmd, vbDirectory) = "") Then * * * * strCmd = "C:\Program Files\Microsoft Office\OFFICE12" * * * * If (Dir(strCmd, vbDirectory) = "") Then * * * * * * MsgBox "Can't find access2007" * * * * * * Exit Function * * * * End If * * End If * * strCmd = strCmd & "\msaccess.exe" * * strCmd = strCmd & " " & Chr(34) & strPath & Chr(34) * * Shell strCmd MsgBox 1 * * Set obj =GetObject(strPath, "Access.Application") MsgBox 2 * * With obj * * * * .Visible = True * * * * .RefreshTitleBar MsgBox "db3" * * End With fexit: * * Exit Function ferr: * * MsgBox "err " & Err.Description End Function- Hide quoted text - - Show quoted text - |
#9
| |||
| |||
|
|
Unfortunately the runtime environment does not support automation or you creating a new instance of access. |
#10
| |||
| |||
|
|
Albert D. Kallal wrote: Unfortunately the runtime environment does not support automation or you creating a new instance of access. I'm curious about that statement. Does that also include Word, Outlook, and Excel? |
![]() |
| Thread Tools | |
| Display Modes | |
| |