J
Jac Tremblay
Hi,
I use Access 2000 and Word 2000 at the office and version 2003 at home.
Through Access, I use automation to create a report. It works fine in 2003
but bugs in the 2000 version after the first report has been produced.
When I run the report in 2000, it works fine the first time. If I do it
again, I get an error message saying that the server control is not available
or has lost it's link (or something like this). See the code below. Does
anyone know about some bug that was corrected in Word 2000? And the way to go
around it.
' ****************************************
' ...
Dim oWord As Word.Application
Dim oDoc As Word.Document
' ...
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Add
oDoc.Activate
With oDoc.ActiveWindow.Selection
..TypeText Text:="Company Name"
..ParagraphFormat.Style = "Title 1"
..TypeParagraph
..TypeText "Report from " & intYear - 1
..ParagraphFormat.Style = "Title 2"
..TypeParagraph
..TypeText "Sickness - " & vbTab & vbTab & " Diagnostic... "
..TypeText "positive - negative"
..ParagraphFormat.Style = "Title 3"
..TypeParagraph
End With
' Here comes the problem...
' I added this line to test if it would work better...
oDoc.Activate
oWord.ActiveDocument.ActiveWindow.Selection.ParagraphFormat.TabStops.Add _
Position:=CentimetersToPoints(8), _
Alignment:=wdAlignTabDecimal, _
Leader:=wdTabLeaderDots
' The rest works fine...
' Save the document.
oWord.ActiveDocument.SaveAs FileName:="Report " & _
intYear - 1, FileFormat:=wdFormatDocument
' ************ End of code *****************
It seems that the reference to the document created is lost somewhere. How
can this be avoided?
That is why I added the "oWord.ActiveDocument.ActiveWindow.Selection"
I wish someone can tell help me.
Thanks.
I use Access 2000 and Word 2000 at the office and version 2003 at home.
Through Access, I use automation to create a report. It works fine in 2003
but bugs in the 2000 version after the first report has been produced.
When I run the report in 2000, it works fine the first time. If I do it
again, I get an error message saying that the server control is not available
or has lost it's link (or something like this). See the code below. Does
anyone know about some bug that was corrected in Word 2000? And the way to go
around it.
' ****************************************
' ...
Dim oWord As Word.Application
Dim oDoc As Word.Document
' ...
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Add
oDoc.Activate
With oDoc.ActiveWindow.Selection
..TypeText Text:="Company Name"
..ParagraphFormat.Style = "Title 1"
..TypeParagraph
..TypeText "Report from " & intYear - 1
..ParagraphFormat.Style = "Title 2"
..TypeParagraph
..TypeText "Sickness - " & vbTab & vbTab & " Diagnostic... "
..TypeText "positive - negative"
..ParagraphFormat.Style = "Title 3"
..TypeParagraph
End With
' Here comes the problem...
' I added this line to test if it would work better...
oDoc.Activate
oWord.ActiveDocument.ActiveWindow.Selection.ParagraphFormat.TabStops.Add _
Position:=CentimetersToPoints(8), _
Alignment:=wdAlignTabDecimal, _
Leader:=wdTabLeaderDots
' The rest works fine...
' Save the document.
oWord.ActiveDocument.SaveAs FileName:="Report " & _
intYear - 1, FileFormat:=wdFormatDocument
' ************ End of code *****************
It seems that the reference to the document created is lost somewhere. How
can this be avoided?
That is why I added the "oWord.ActiveDocument.ActiveWindow.Selection"
I wish someone can tell help me.
Thanks.