A
Aleksey Ivkov
I have a simple application, which looks like this:
<-
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Test"
Height = 1215
Left = 960
TabIndex = 0
Top = 1080
Width = 2895
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private myWordApp As Word.Application
Private wordDoc As Word.Document
Private templatePath As String
Private Sub Command1_Click()
Set myWordApp = CreateObject("Word.Application")
myWordApp.Visible = True
MsgBox "before opening", vbCritical, "Test"
Set wordDoc = myWordApp.Documents.Open("C:\Test.doc")
MsgBox "after opening", vbCritical, "Test"
End Sub
->
The script opens Word and displays the "before opening" message but as soon
as the Set wordDoc = myWordApp.Documents.Open("C:\Test.doc") command is
called, the attached error message ("Dr.Watson") will appear and the VB
executable will crash. The same command works on Word 2003. I tried creating
vbs script and run it - everything is working just fine. What could be the
problem? Anyone?
<-
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Test"
Height = 1215
Left = 960
TabIndex = 0
Top = 1080
Width = 2895
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private myWordApp As Word.Application
Private wordDoc As Word.Document
Private templatePath As String
Private Sub Command1_Click()
Set myWordApp = CreateObject("Word.Application")
myWordApp.Visible = True
MsgBox "before opening", vbCritical, "Test"
Set wordDoc = myWordApp.Documents.Open("C:\Test.doc")
MsgBox "after opening", vbCritical, "Test"
End Sub
->
The script opens Word and displays the "before opening" message but as soon
as the Set wordDoc = myWordApp.Documents.Open("C:\Test.doc") command is
called, the attached error message ("Dr.Watson") will appear and the VB
executable will crash. The same command works on Word 2003. I tried creating
vbs script and run it - everything is working just fine. What could be the
problem? Anyone?