Link to home
Start Free TrialLog in
Avatar of Armando Vilela Baiões
Armando Vilela BaiõesFlag for Portugal

asked on

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

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

Avatar of Helen Feddema
Helen Feddema
Flag of United States of America image

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)?
Avatar of Armando Vilela Baiões

ASKER

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.
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.
I quit (for today), maybe i need some rest... If anyone have any ideia, please post!
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

ASKER CERTIFIED SOLUTION
Avatar of Armando Vilela Baiões
Armando Vilela Baiões
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Working Code