Hi guys, I don't post that often, but any help will be appreciated.
This is a segment of code that I wrote (with some of the information blanked out) that seems to be hitting a error code '462'. This deals directly with VB6 and Microsoft Word. The users are on different platforms in Microsoft (including NT, 2000, and XP). The Microsoft Office Suites are different versions as well. I really need help. I can't seem to pinpoint to code error.
Also, I am using a spell checker module of code I got online.
'Copyright © 2005 by RobDog888 (VB/Office Guru™). All Rights reserved.
The spell checker works well, but does not work when someones Outlook Email Checker is open (tied to word). Any ideas if there is a way to fix this? Thanks.
Code:
Dim objWrd As Object
Set objWrd = CreateObject("Word.Application")
'Dim objWrd As New Word.Application
Dim objDoc As Word.Document
Dim sln As Word.Selection
'Setting Overtype value to False is very impotant when using selection
objWrd.Options.Overtype = False
Select Case objWrd.Version
Case "9.0", "10.0", "11.0"
Set objDoc = objWrd.Documents.Add(, , 1, True)
Case "8.0"
Set objDoc = objWrd.Documents.Add
Case Else
MsgBox "Unsupported Version of Word.", vbOKOnly + vbExclamation, "Install New Version"
Exit Sub
End Select
Set sln = objWrd.Selection
objDoc.Activate
With sln
.Paragraphs.Alignment = wdAlignParagraphLeft
.Font.Name = "Arial"
.Font.Size = cboFontSize.Text + 2
.BoldRun
.TypeText (Chr(9) & lblDefName.Caption)
.BoldRun
.TypeParagraph
.TypeParagraph
.Font.Size = cboFontSize.Text
'*NEWLINE*
.BoldRun
.TypeText (Chr(9) & " ")
.BoldRun
.TypeText (txtSPN.Text)
.BoldRun
.TypeText (" ")
.BoldRun
Dim i As Integer
For i = 0 To lstCause.ListCount
.TypeText (lstCause.List(i) & " ")
Next i
.TypeParagraph
'*NEWLINE*
.BoldRun
.TypeText (Chr(9) & " ")
.BoldRun
.TypeText (txtDateAct.Text)
.BoldRun
.TypeText (" ")
.BoldRun
.TypeText (cboActType.Text)
.BoldRun
.TypeText (" ")
.BoldRun
.TypeText (txtLOS_lbl.Caption)
.TypeParagraph
.TypeParagraph
'*NEWLINE*
'*NEWLINE*
.BoldRun
.TypeText (" ")
.BoldRun
.TypeParagraph
.TypeText (txtNotes.Text)
.TypeParagraph
If (txtRptDate <> vbNullString) Then
.BoldRun
.TypeText (" ")
.BoldRun
.TypeText (txtRptDate.Text)
.TypeText (" ")
.BoldRun
.TypeText (" ")
.BoldRun
.TypeText (txtRptTime.Text)
End If
.TypeParagraph
.BoldRun
.TypeText (" ")
.BoldRun
.TypeText (lblCSO.Caption)
.ItalicRun
.TypeText (" ")
.ItalicRun
End With
objWrd.Visible = True
objWrd.PrintOut
objWrd.Visible = False
MsgBox "Successfully Printed", vbOKOnly, "Print Successful"
objDoc.Close (False)
objWrd.Quit (False)
This is a segment of code that I wrote (with some of the information blanked out) that seems to be hitting a error code '462'. This deals directly with VB6 and Microsoft Word. The users are on different platforms in Microsoft (including NT, 2000, and XP). The Microsoft Office Suites are different versions as well. I really need help. I can't seem to pinpoint to code error.
Also, I am using a spell checker module of code I got online.
'Copyright © 2005 by RobDog888 (VB/Office Guru™). All Rights reserved.
The spell checker works well, but does not work when someones Outlook Email Checker is open (tied to word). Any ideas if there is a way to fix this? Thanks.