J
Joop
Hi all,
In an Access VBA app that I developed I start Word with a template and fill
the bookmarks in the template with data from Access. When the document is
filled I want to place the cursor on the right spot so the user can start
typing immidiately. The code looks as follows:
With WApp.ActiveDocument
.Bookmarks("BedrNaam").Range.Text = Me!FldBedrNaam
.Bookmarks("ContPers").Range.Text = Me!TxtAHKort
.Bookmarks("Onderw").Range.Text = Me!TxtOnderwerp
.Bookmarks("FaxNummer").Range.Text = Me!FldFax
End With
WApp.ActiveDocument.SaveAs FileName:=RootString & DocPadString &
Trim(Str(Year(Date))) & "\" & TypeString & CorNumString
Debug.Print WApp.ActiveDocument.Name
If OptBrFEM = 1 Then Selection.GoTo what:=wdGoToLine,
which:=wdGoToAbsolute, Count:=17
If OptBrFEM = 2 Then Selection.GoTo what:=wdGoToLine,
which:=wdGoToAbsolute, Count:=15
If OptBrFEM = 3 Then Selection.GoTo what:=wdGoToLine,
which:=wdGoToAbsolute, Count:=5
WApp.Visible = True
WApp.Activate
Up to the positioning of the cursor everything works well, but the
"Selection.GoTo" often (not always) goes wrong.
When it goes wrong I get a error 462 in Access (The external Servercomputer
does not exist or is not available, I don't know if this is the right text
as it is translated fron dutch)
When I activate Word verything looks normal, all data is there.
MOst of the times it works ok the first time Word is started. It looks as if
there is a difference between closing Word or closing just the document
after the document is finished.
Is it a bug???
regards Joop
In an Access VBA app that I developed I start Word with a template and fill
the bookmarks in the template with data from Access. When the document is
filled I want to place the cursor on the right spot so the user can start
typing immidiately. The code looks as follows:
With WApp.ActiveDocument
.Bookmarks("BedrNaam").Range.Text = Me!FldBedrNaam
.Bookmarks("ContPers").Range.Text = Me!TxtAHKort
.Bookmarks("Onderw").Range.Text = Me!TxtOnderwerp
.Bookmarks("FaxNummer").Range.Text = Me!FldFax
End With
WApp.ActiveDocument.SaveAs FileName:=RootString & DocPadString &
Trim(Str(Year(Date))) & "\" & TypeString & CorNumString
Debug.Print WApp.ActiveDocument.Name
If OptBrFEM = 1 Then Selection.GoTo what:=wdGoToLine,
which:=wdGoToAbsolute, Count:=17
If OptBrFEM = 2 Then Selection.GoTo what:=wdGoToLine,
which:=wdGoToAbsolute, Count:=15
If OptBrFEM = 3 Then Selection.GoTo what:=wdGoToLine,
which:=wdGoToAbsolute, Count:=5
WApp.Visible = True
WApp.Activate
Up to the positioning of the cursor everything works well, but the
"Selection.GoTo" often (not always) goes wrong.
When it goes wrong I get a error 462 in Access (The external Servercomputer
does not exist or is not available, I don't know if this is the right text
as it is translated fron dutch)
When I activate Word verything looks normal, all data is there.
MOst of the times it works ok the first time Word is started. It looks as if
there is a difference between closing Word or closing just the document
after the document is finished.
Is it a bug???
regards Joop