Re: VBA (in Access) to Microstation gives error 462
- From: "Norman Yuan" <FakeName@xxxxxxxxxxxxx>
- Date: Sun, 12 Apr 2009 06:36:49 -0700
See comment inline.
"Clif McIrvin" <clare.moe@xxxxxxxxxxxxxxxxxxxxxx> wrote in message news:%23sHMr7VuJHA.4928@xxxxxxxxxxxxxxxxxxxxxxx
Boy does that sound familiar! I was attempting to launch an Access Macro from Excel [Office 2003].
I observed an error 462 every ODD launch of my code; it ran successfully every EVEN launch. I never did understand why ... the problem eventually went away and I still don't understand why.
Relevant code snippets and comments from my experience follow:
Sub RunAccessMacro()
' Error: 462 The remote server machine does not exist or is unavailable
' Error: 7867 You already have the database open.
Const comNA As Integer = 462
Const dbOpen As Integer = 7867
Dim appAcc As Access.Application
Dim AccWasOpen As Boolean
Set appAcc = Access.Application
With appAcc
Is this your real code used in Excel VBA? If so, you should get error without question: the code does not instantiate an Access.Application object. It should be:
Set appAcc=New Access.Application
or
Set appAcc=CreateObject("Access.Application")
or
''If you want to connect your Excel to an existing running Access session
Set appAcc=GetObject(,"Access.Application")
As for our code may work when re-launch (I am not sure why it is that every EVEN number of re-launch works), it may because of VB does some thing behind of scene with the not correctly instantiated appAcc object. VB/A sometimes does too much on its own.
Anyway, good code should obtain the appAcc object correctly and close it correctly when you are done with it.
' Testing so far shows Remote Server Not Available error
' every other launch of the macro. I have absolutely no
' clue why; nor why a re-launch works. (5/02/08)
' Testing shows that if Access is closed, or open without
' a database then .CurrentDb returns Nothing
On Error Resume Next
AccWasOpen = (.CurrentDb Is Nothing)
If Err.Number = comNA Then GoTo ExitSub
On Error GoTo 0
' Interesting: after putting in the above test I've not seen
' the exit triggered!
Hopefully either 1) this helps you or (better yet!) 2) someone will be able to explain this to us!
--
Clif
"djw" <david.j.winfield@xxxxxxxxx> wrote in message news:2d59f5d7-d88a-4d14-9cf2-5a02b74b1c3d@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxI am trying to use VBA in one program (Access) to perform some
operations in another (Microstation V8). When I run the code the
first time I get error 462. The second time I run the code it works
fine. Here is the error message:
Run-time error '462':
The remote server machine does not exist or is unavailable
An example line of code that will give the error is:
With MicroStationDGN.Application.CadInputQueue
.SendCommand "PRINT COLORMODE MONOCHROME"
.SendCommand "PRINT FULL*** ON"
.SendCommand "PRINT maximize
.SendCommand "PRINT EXECUTE "
End With
I have the "Bentley MicroStation DGN 8.0 Object Library" reference
turned on for the project.
Thanks for any help you can provide,
David
--
Clif
.
- Follow-Ups:
- Re: VBA (in Access) to Microstation gives error 462
- From: Clif McIrvin
- Re: VBA (in Access) to Microstation gives error 462
- References:
- VBA (in Access) to Microstation gives error 462
- From: djw
- Re: VBA (in Access) to Microstation gives error 462
- From: Clif McIrvin
- VBA (in Access) to Microstation gives error 462
- Prev by Date: Re: VBA (in Access) to Microstation gives error 462
- Next by Date: Re: VBA (in Access) to Microstation gives error 462
- Previous by thread: Re: VBA (in Access) to Microstation gives error 462
- Next by thread: Re: VBA (in Access) to Microstation gives error 462
- Index(es):