VBA (in Access) to Microstation gives error 462

D

djw

I 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 FULLSHEET 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
 
D

djw

Clif,

Thank you for your reply. Let me try to clarify what is going on a
little more. It seems that it doesn't give the error every other time
I run the code just the first time I run it for an instance of a
Microstation drawing.

I am trying to perform an operation on the currently open Microstation
file. The first time I run it for that file it will give the error
but every run after that will work. But if I close and re-open
Microstation it will give the error again when the code is first run
(Access remains open while Microstation is restarted).

I have tried using On Error a few ways to try to get around this. It
seems that if I do an on Error Resume Next it just keeps erroring out
and skipping those lines (I tried just looping through and running the
code twice without throwing the error message). It is like the error
Message is actually performing some kind of operation that effects how
the code is run the second time around.

Thanks again,
David

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

' 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




I 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 FULLSHEET 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
 
C

Clif McIrvin

David --
I wish I knew enough about these things to have some insight. It does
sound like you are seeing different behavior than I did, and in fact I
never knew what made the behavior I was seeing change.

This post in the Access newsgroup from Tom Wickerath might have useful
information:


If that link doesn't open up for you, here's a google groups link to an
earlier post in the same thread:



HTH!
--
Clif

Clif,

Thank you for your reply. Let me try to clarify what is going on a
little more. It seems that it doesn't give the error every other time
I run the code just the first time I run it for an instance of a
Microstation drawing.

I am trying to perform an operation on the currently open Microstation
file. The first time I run it for that file it will give the error
but every run after that will work. But if I close and re-open
Microstation it will give the error again when the code is first run
(Access remains open while Microstation is restarted).

I have tried using On Error a few ways to try to get around this. It
seems that if I do an on Error Resume Next it just keeps erroring out
and skipping those lines (I tried just looping through and running the
code twice without throwing the error message). It is like the error
Message is actually performing some kind of operation that effects how
the code is run the second time around.

Thanks again,
David

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

' 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




I 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 FULLSHEET 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
 
D

djw

I found something in the Microstation Help file that was useful.
Apparently if I do the following it solves the problem:

Dim M_app As ApplicationObjectConnector
Set M_app = GetObject(, "MicroStationDGN.ApplicationObjectConnector")

With M_app.Application.CadInputQueue
.SendCommand "PRINT COLORMODE MONOCHROME"
.SendCommand "PRINT FULLSHEET ON"
.SendCommand "PRINT maximize"
.SendCommand "PRINT EXECUTE "
End With



David --
 I wish I knew enough about these things to have some insight.  It does
sound like you are seeing different behavior than I did, and in fact I
never knew what made the behavior I was seeing change.

This post in the Access newsgroup from Tom Wickerath might have useful
information:


If that link doesn't open up for you, here's a google groups link to an
earlier post in the same thread:


HTH!
--
Clif


Clif,

Thank you for your reply.  Let me try to clarify what is going on a
little more.  It seems that it doesn't give the error every other time
I run the code just the first time I run it for an instance of a
Microstation drawing.

I am trying to perform an operation on the currently open Microstation
file.  The first time I run it for that file it will give the error
but every run after that will work.  But if I close and re-open
Microstation it will give the error again when the code is first run
(Access remains open while Microstation is restarted).

I have tried using On Error a few ways to try to get around this.  It
seems that if I do an on Error Resume Next it just keeps erroring out
and skipping those lines (I tried just looping through and running the
code twice without throwing the error message).   It is like the error
Message is actually performing some kind of operation that effects how
the code is run the second time around.

Thanks again,
David

Boy does that sound familiar! I was attempting to launch an Access
Macro from Excel [Office 2003].
I observed an error462every 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:462The 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
' 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!
 
C

Clif McIrvin

Thank you for sharing that. I'll have to look into that
ApplicationObjectConnector.

I found something in the Microstation Help file that was useful.
Apparently if I do the following it solves the problem:

Dim M_app As ApplicationObjectConnector
Set M_app = GetObject(, "MicroStationDGN.ApplicationObjectConnector")

With M_app.Application.CadInputQueue
.SendCommand "PRINT COLORMODE MONOCHROME"
.SendCommand "PRINT FULLSHEET ON"
.SendCommand "PRINT maximize"
.SendCommand "PRINT EXECUTE "
End With



David --
I wish I knew enough about these things to have some insight. It does
sound like you are seeing different behavior than I did, and in fact I
never knew what made the behavior I was seeing change.

This post in the Access newsgroup from Tom Wickerath might have useful
information:


If that link doesn't open up for you, here's a google groups link to
an
earlier post in the same thread:


HTH!
--
Clif


Clif,

Thank you for your reply. Let me try to clarify what is going on a
little more. It seems that it doesn't give the error every other time
I run the code just the first time I run it for an instance of a
Microstation drawing.

I am trying to perform an operation on the currently open Microstation
file. The first time I run it for that file it will give the error
but every run after that will work. But if I close and re-open
Microstation it will give the error again when the code is first run
(Access remains open while Microstation is restarted).

I have tried using On Error a few ways to try to get around this. It
seems that if I do an on Error Resume Next it just keeps erroring out
and skipping those lines (I tried just looping through and running the
code twice without throwing the error message). It is like the error
Message is actually performing some kind of operation that effects how
the code is run the second time around.

Thanks again,
David

Boy does that sound familiar! I was attempting to launch an Access
Macro from Excel [Office 2003].
I observed an error462every 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:462The 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
' 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!
 
N

Norman Yuan

See comment inline.


Clif McIrvin said:
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.
 
N

Norman Yuan

"ApplicationObjectConnector" will not be applicable to your case. It is
Microstation's API. See my comment to your previous post.

Clif McIrvin said:
Thank you for sharing that. I'll have to look into that
ApplicationObjectConnector.

I found something in the Microstation Help file that was useful.
Apparently if I do the following it solves the problem:

Dim M_app As ApplicationObjectConnector
Set M_app = GetObject(, "MicroStationDGN.ApplicationObjectConnector")

With M_app.Application.CadInputQueue
.SendCommand "PRINT COLORMODE MONOCHROME"
.SendCommand "PRINT FULLSHEET ON"
.SendCommand "PRINT maximize"
.SendCommand "PRINT EXECUTE "
End With



David --
I wish I knew enough about these things to have some insight. It does
sound like you are seeing different behavior than I did, and in fact I
never knew what made the behavior I was seeing change.

This post in the Access newsgroup from Tom Wickerath might have useful
information:


If that link doesn't open up for you, here's a google groups link to an
earlier post in the same thread:


HTH!
--
Clif


Clif,

Thank you for your reply. Let me try to clarify what is going on a
little more. It seems that it doesn't give the error every other time
I run the code just the first time I run it for an instance of a
Microstation drawing.

I am trying to perform an operation on the currently open Microstation
file. The first time I run it for that file it will give the error
but every run after that will work. But if I close and re-open
Microstation it will give the error again when the code is first run
(Access remains open while Microstation is restarted).

I have tried using On Error a few ways to try to get around this. It
seems that if I do an on Error Resume Next it just keeps erroring out
and skipping those lines (I tried just looping through and running the
code twice without throwing the error message). It is like the error
Message is actually performing some kind of operation that effects how
the code is run the second time around.

Thanks again,
David

Boy does that sound familiar! I was attempting to launch an Access
Macro from Excel [Office 2003].
I observed an error462every 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:462The 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
' 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!


I 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 error462. 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 FULLSHEET 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
 
D

david

I observed an error 462 every ODD launch of my code; it ran

That was an installation problem, and it was solved by doing a
correct installation, or by running the application with permission
to do a correct installation, or by installing the service pack. The
odd/even behaviour is caused by a flag alternatively being set/
cleared in the "Machine" and the "Current User" areas of the registry.



Clif McIrvin said:
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

' 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 said:
I 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 FULLSHEET 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
 
C

Clif McIrvin

david said:
That was an installation problem, and it was solved by doing a
correct installation, or by running the application with permission
to do a correct installation, or by installing the service pack. The
odd/even behaviour is caused by a flag alternatively being set/
cleared in the "Machine" and the "Current User" areas of the registry.


Thank you! That explains a lot. I don't recall just when I installed
SP3 and the hotfix .. .I could easily have not noticed the correlation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top