|
-
May 30th, 2000, 11:24 PM
#1
Thread Starter
Addicted Member
I've written a simple program in VB, which creates an instance of a Word application, enters some text, and saves the document.
Here is a sample of what I have:
Code:
Set objWord = New Word.Application
Set doc1 = objWord.Documents.Open("c:\temp\report.doc")
With objWord.Selection
.EndKey Unit:=wdStory
.Tables.Add Range:=objWord.Selection.Range, NumRows:=1, NumColumns:=5
.TypeText Text:="First Name"
.MoveRight Unit:=wdCell
.TypeText Text:="Last Name"
'do more editing of the document here
End With
'save the file
doc1.SaveAs FileName:="c:\temp\report1.doc"
doc1.Close
objWord.Quit
it works fine. But what I want to do now is have this run in VBScript. I know that from VBScript I can create an instance of a Word Application, but when I tried to run this as above, it screamed at me when it tried to compile
Code:
.EndKey Unit:=wdStory
Could someone please indicate why this will not work in VBScript. Or can I even do this in VBScript. Does anyone know of a resource where I can find how to refer to the Word Object Model in VBScript ??
tx
-
May 31st, 2000, 05:23 AM
#2
Fanatic Member
Well, the simple problem is that VBScript doesn't like to use the With statement with objects that are not in its own object library. Try taking the With Statement out and putting the objWord.Selection infront of the other lines. The object model in VBScript is the same as it is when you're in VB or Word itself. You can use the Word VBA Help File or go to http://msdn.microsoft.com/officedev/.
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
|