P
pstachel
Guest
In Access I have made a VBA module to open a Word document to insert some information from a Access data base to be printed. The module so far works but only once after system start. It does start if I start it a second time but stops a soon as I try to access any "ActiveDocument....) statement with a meassage :"The remote server-computer does not exist". If I shut down and reboot the coputer it does work properly once and stops at the second try as described.
I would not need Word if only Access could handle reports longer then 55 cm. Unfortunately my report is longer and I can not print it in 6 pixel writing, someone should be able to read it.
Either somebody can teach me how to create longer reports or I have to find a solution with the word problem.
Any help is appriciated.
See code below.
Private Sub Test_2()
'***************************************************************************************************
' Schreibt Produkt und Rezeptur in Word SDS
'
'*****************************************************************************************************
Dim stAppName As String
stAppName = "WINWORD.exe C:\Stachel\db3\Feld.doc"
Set oApp = CreateObject("Word.Application")
Call Shell(stAppName, 1)
MsgBox ("Vor Feld")
Debug.Print "Vor Active"
' at the second try it stops at this point and says "Remote-server does not exist ...."
ActiveDocument.Variables("Produkt").Value = "SMC ßßßßßßß"
Debug.Print " Nach Active"
ActiveDocument.Variables("Rezeptur").Value = "-----1/12"
ActiveDocument.Fields.Update
Debug.Print ActiveDocument.Variables(1).Name
Debug.Print ActiveDocument.Variables(2).Name
Debug.Print ActiveDocument.Variables(3).Name
Debug.Print "Nach Input Variablen"
Debug.Print "Active Document is: " & ActiveDocument.Name
MsgBox ("Nach Zoro")
oApp.Quit savechanges:=False
End Sub
I would not need Word if only Access could handle reports longer then 55 cm. Unfortunately my report is longer and I can not print it in 6 pixel writing, someone should be able to read it.
Either somebody can teach me how to create longer reports or I have to find a solution with the word problem.
Any help is appriciated.
See code below.
Private Sub Test_2()
'***************************************************************************************************
' Schreibt Produkt und Rezeptur in Word SDS
'
'*****************************************************************************************************
Dim stAppName As String
stAppName = "WINWORD.exe C:\Stachel\db3\Feld.doc"
Set oApp = CreateObject("Word.Application")
Call Shell(stAppName, 1)
MsgBox ("Vor Feld")
Debug.Print "Vor Active"
' at the second try it stops at this point and says "Remote-server does not exist ...."
ActiveDocument.Variables("Produkt").Value = "SMC ßßßßßßß"
Debug.Print " Nach Active"
ActiveDocument.Variables("Rezeptur").Value = "-----1/12"
ActiveDocument.Fields.Update
Debug.Print ActiveDocument.Variables(1).Name
Debug.Print ActiveDocument.Variables(2).Name
Debug.Print ActiveDocument.Variables(3).Name
Debug.Print "Nach Input Variablen"
Debug.Print "Active Document is: " & ActiveDocument.Name
MsgBox ("Nach Zoro")
oApp.Quit savechanges:=False
End Sub