We help IT Professionals succeed at work.

I get vba error 462 the remote server machine does not exist or is unavailable

308 Views
Last Modified: 2017-03-17
Hello Fellows

I get the above error when i run the code bellow , but when i re-run it after the error occur, the code seems to Work fine. For sure im missing something in it. Can you point me the right way to do this?



Thanks in advanced.

First sub:

Private Sub Command54_Click()


Forms!frmFScomposicao!subfrmKitCenas![FSKitCenasOLE].Verb = acOLEVerbOpen
Forms!frmFScomposicao!subfrmKitCenas![FSKitCenasOLE].Verb = acOLEVerbOpen
Set GeraKit0 = Forms!frmFScomposicao!subfrmKitCenas!FSKitCenasOLE.Range

With GeraKit0.Select
GeraKit0.WholeStory
GeraKit0.Delete
End With

Dim FirstTime As Integer
FirstTime = 1

Me.FirstTimeBox = FirstTime

Forms!frmFScomposicao!PRODUCAO.SetFocus

DoCmd.RunCommand acCmdRecordsGoToFirst
For f = 1 To Forms!frmFScomposicao!PRODUCAO![Tiroliro]
Me.FirstTimeBox = FirstTime

Call CompilarKitDiaGravacao
Forms!frmFScomposicao!PRODUCAO.SetFocus
FirstTime = FirstTime + 1

DoCmd.RunCommand acCmdRecordsGoToNext

Next f

DoCmd.RunCommand acCmdRecordsGoToFirst

End Sub

Open in new window



Second sub:

Public Sub CompilarKitDiaGravacao()
'Set cenaspararecolher = Forms!frmFScomposicao!PRODUCAO.Action = acOLEActivate
Set cenaspararecolher = Forms!frmFScomposicao!PRODUCAO![Prod_Cena_Guiao].Range
With cenaspararecolher.Select
cenaspararecolher.WholeStory
cenaspararecolher.Copy
Set cenaspararecolher = Nothing
End With

If Forms!frmFScomposicao.FirstTimeBox = 1 Then

Set Vinho = Forms!frmFScomposicao!subfrmKitCenas!FSKitCenasOLE.Range
With Vinho.Select
Selection.EndKey wdStory
Selection.InsertBreak Type:=wdSectionBreakContinuous
Selection.PasteAndFormat wdPasteDefault
End With
Forms!frmFScomposicao!FirstTimeBox = Forms!frmFScomposicao!FirstTimeBox + 1

Else

Set Vinho = Forms!frmFScomposicao!subfrmKitCenas!FSKitCenasOLE.Range
With Vinho.Select
Selection.EndKey wdStory
Selection.InsertBreak 'Type:=wdSectionBreakContinuous
Selection.PasteAndFormat wdPasteDefault
End With
 End If


End Sub

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2009

Commented:
It seems that you are somehow working with a Word document (as indicated by some of the code, such as inserting a continuous section break), but I don't see code to either create a Word doc or set a reference to an existing doc.  What exactly is the code doing (in words)?

Author

Commented:
Hello.
I have a main form with two sub forms one of the sub forms contains a list of several OLE selected word documents, in which I loop, passing all these documents to another sub form, which also contains an OLE Field, which will gather these Documents, in one.

Author

Commented:
It may be something to do with one of the subforms, only when I make the selection of new documents the error occurs the first time I try the code, then if I try again, the code works.

Author

Commented:
I quit (for today), maybe i need some rest... If anyone have any ideia, please post!

Author

Commented:
I made some changes to the code, but im still getting the same error, but on a diferent line (underscored).

Heres the code so far:

Public Sub CompilarKitDiaGravacao()

Dim CenasParaRecolha As Object
Dim DocumentoDestino As Object

        Set CenasParaRecolha = Forms!frmFScomposicao!PRODUCAO![Prod_Cena_Guiao].Object.Application.WordBasic
        Forms!frmFScomposicao!PRODUCAO![Prod_Cena_Guiao].Action = acOLEActivate
        With CenasParaRecolha
        Selection.WholeStory
        Selection.Copy
        End With

If Forms!frmFScomposicao.FirstTimeBox = 1 Then
    
    Forms!frmFScomposicao!subfrmKitCenas![FSKitCenasOLE].Action = acOLEPaste

        Set DocumentoDestino = Forms!frmFScomposicao!subfrmKitCenas![FSKitCenasOLE].Object.Application.WordBasic
        Forms!frmFScomposicao!subfrmKitCenas![FSKitCenasOLE].Action = acOLEActivate
        With DocumentoDestino
        Selection.WholeStory
        Selection.Delete
        Selection.EndKey wdStory
        Selection.InsertBreak Type:=wdSectionBreakContinuous
        Selection.PasteAndFormat wdPasteDefault
        End With

    Forms!frmFScomposicao!FirstTimeBox = Forms!frmFScomposicao!FirstTimeBox + 1

Else

        Set DocumentoDestino = Forms!frmFScomposicao!subfrmKitCenas![FSKitCenasOLE].Object.Application.WordBasic
        Forms!frmFScomposicao!subfrmKitCenas![FSKitCenasOLE].Action = acOLEActivate
        With DocumentoDestino
        Selection.EndKey wdStory
        Selection.InsertBreak 'Type:=wdSectionBreakContinuous
        Selection.PasteAndFormat wdPasteDefault
        End With
 
End If

Set CenasParaRecolha = Nothing
Set DocumentoDestino = Nothing
End Sub

Open in new window

Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Working Code