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

Microsoft AccessVBA

Avatar of undefined
Last Comment
Armando Vilela Baiões

8/22/2022 - Mon
Helen Feddema

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

ASKER
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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Armando Vilela Baiões

ASKER
I quit (for today), maybe i need some rest... If anyone have any ideia, please post!
Armando Vilela Baiões

ASKER
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
Armando Vilela Baiões

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Armando Vilela Baiões

ASKER
Working Code
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.