|
-
Sep 24th, 2001, 09:49 AM
#1
Thread Starter
Member
Calling Word
Yeah, the code is probably sloppy. I am not really a programmer, but,..
I am calling Word to create a document. On my machine, running ME and Word 2000, everything works fine. On any machine running Word 98, I am getting a fatal error. Code is below. ANy ideas why this is happening? It appears that Word object is opening, then the documents is not.
Tahnks,
Tim
----------------------------------------------------------------
Private Sub CreateDoc()
Dim ssLine As String
Dim LMode As String
Dim LIllPrem As String
Dim LPayTo As String
Dim Riders As String
Dim LLZip As String
Dim LLAZip As String
Dim Range1 As Range
Dim Range2 As Range
Dim Range3 As Range
Dim Range4 As Range
Dim Range5 As Range
Dim Range6 As Range
Dim Range7 As Range
Dim Range8 As Range
Dim Range9 As Range
Dim Range10 As Range
Dim Range11 As Range
Dim Range12 As Range
Dim Range13 As Range
Dim Range14 As Range
Dim Range20 As Range
Dim Range21 As Range
Dim rng As Range
Dim Sect As Section
Dim Class As String
Dim WLType As String
Dim FWLType As String
Dim ThisDoc As Document
Dim sForm As String
If ObjWord Is Nothing Then
Set ObjWord = CreateObject("Word.Application")
Else
Set ObjWord = GetObject(, "Word.Application")
End If
ObjWord.WindowState = wdWindowStateMaximize
ObjWord.Visible = True
If SSTabLife.Caption = "Senior Security" Then
Set ThisDoc = Documents.Open(FileName:="C:\Program Files\BFL\WLIll.doc")
ElseIf SSTabLife.Caption = "Whole Life" Then
Set ThisDoc = Documents.Open(FileName:="C:\Program Files\BFL\SSIll.doc")
End If
LName = txtName
LAge = txtAge
LFace = c_mskFace
LLFace = Format(LFace, "##,###,##0")
LPayTo = GetIllPayTo()
sForm = GetForm()
If LSuffix = " " Then
LLZip = LZip
Else
LLZip = LZip & "-" & LSuffix
End If
If LASuffix = " " Then
LLAZip = LAZip
Else
LLAZip = LAZip & "-" & LASuffix
End If
If LAExt = "" Then
LLAPhone = LAPhone
Else
LLAPhone = LAPhone & " Ext. " & LAExt
End If
LMode = GetCaption()
LIllPrem = Format(GetIllPrem(), "###,###.00")
Riders = PrintRiders()
WLType = GetWLType()
FWLType = GetFWLType()
ObjWord.ActiveDocument.SaveAs FileName:="TempIll.doc"
Set Range1 = ObjWord.ActiveDocument.Content
Range1.Find.Execute FindText:="Designed for:", Forward:=True
If Range1.Find.Found = True Then Range1.InsertAfter Text:=vbCrLf & txtName & vbCrLf & _
LAdd & " " & LApart & vbCrLf & LCity & ", " & LState & " " & LLZip
Set Range2 = ObjWord.ActiveDocument.Content
Range2.Find.Execute FindText:="Presented By:", Forward:=True
If Range2.Find.Found = True Then Range2.InsertAfter Text:=vbCrLf & LAName & vbCrLf & _
LAAdd & " " & LAApart & vbCrLf & LACity & ", " & LAState & " " & LLAZip & vbCrLf & _
LLAPhone
Set Range3 = ObjWord.ActiveDocument.Content
Range3.Find.Execute FindText:="License Number:", Forward:=True
If Range3.Find.Found = True Then Range3.InsertAfter Text:=vbCrLf & LALicNum
Set Range4 = ObjWord.ActiveDocument.Content
Range4.Find.Execute FindText:="Page 2 Prepared for:", Forward:=True
If Range4.Find.Found = True Then Range4.InsertAfter Text:=vbCrLf & txtName & _
vbCrLf & "Age: " & LAge & " Sex: " & LGender
Set Range5 = ObjWord.ActiveDocument.Content
Range5.Find.Execute FindText:="Page 3 Prepared for:", Forward:=True
If Range5.Find.Found = True Then Range5.InsertAfter Text:=vbCrLf & txtName & _
vbCrLf & "Age: " & LAge & " Sex: " & LGender
Set Range6 = ObjWord.ActiveDocument.Content
Range6.Find.Execute FindText:="assuming that this is a ", Forward:=True
If Range6.Find.Found = True Then Range6.InsertAfter Text:=WLType
Set Range7 = ObjWord.ActiveDocument.Content
Range7.Find.Execute FindText:="at issue is assumed to be $", Forward:=True
If Range7.Find.Found = True Then Range7.InsertAfter Text:=LLFace
If SSTabLife.Caption = "Senior Security" Then
Set Range8 = ObjWord.ActiveDocument.Content
Range8.Find.Execute FindText:="Designed for:", Forward:=True
If Range8.Find.Found = True Then Range8.InsertBefore Text:=WLType & vbCrLf & _
"Senior Security Whole Life" & vbCrLf & vbCrLf & vbCrLf
Else
Set Range8 = ObjWord.ActiveDocument.Content
Range8.Find.Execute FindText:="Designed for:", Forward:=True
If Range8.Find.Found = True Then Range8.InsertBefore Text:=FWLType & vbCrLf & _
"Whole Life" & vbCrLf & vbCrLf & vbCrLf
End If
Set Range9 = ObjWord.ActiveDocument.Content
Range9.Find.Execute FindText:=", and is guaranteed by the company.", Forward:=True
If Range9.Find.Found = True Then Range9.InsertBefore Text:=LMode & " $" & LIllPrem
Set Range10 = ObjWord.ActiveDocument.Content
Range10.Find.Execute FindText:="Premiums are payable", Forward:=True
If Range10.Find.Found = True Then Range10.InsertAfter Text:=" " & LPayTo & "."
Set Range12 = ObjWord.ActiveDocument.Content
Range12.Find.Execute FindText:="Underwriting Class:", Forward:=True
If Range12.Find.Found = True Then Range12.InsertAfter Text:=vbCrLf & WLType
Set Range13 = ObjWord.ActiveDocument.Content
Range13.Find.Execute FindText:="Face Amount:", Forward:=True
If Range13.Find.Found = True Then Range13.InsertAfter Text:=" $" & LLFace & vbCrLf _
& vbCrLf & vbCrLf & LMode & ": $" & LIllPrem
Set Range14 = ObjWord.ActiveDocument.Content
Range14.Find.Execute FindText:="included in the premium.", Forward:=True
If Range14.Find.Found = True Then Range14.InsertBefore Text:=PrintRiders()
Set Range20 = ObjWord.ActiveDocument.Content
Range20.Find.Execute FindText:="Policy Values Table", Forward:=True
If Range20.Find.Found = True Then Range20.InsertAfter Text:=vbTab & vbCrLf & vbCrLf & TableValues()
Do While ObjWord.BackgroundPrintingStatus > 0
Debug.Print ObjWord.BackgroundPrintingStatus
Loop
rsCV.Close
rsCVT.Close
'ObjWord.Quit wdDoNotSaveChanges
End Sub
Tim
VB6, SP4
GT Vengeance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|