|
-
Mar 20th, 2002, 06:19 PM
#1
Thread Starter
New Member
Writing Word document with VB6
I am writing a VB6 application that writes to a Word 2000 document. I want to control when a new page is added to the document and set the template the new page will use. There is no user interface while the document is being written by VB. Logic in the application is writing the document.
Comments please.
-
Mar 20th, 2002, 06:52 PM
#2
Addicted Member
Word 2000 should have an Automation interface that can be accessed from VB.
-
Mar 20th, 2002, 07:21 PM
#3
Thread Starter
New Member
Yes it does have an automation interface, I have looked in the Word 2000 developer's handbook and VB help. I can find nothing that shows me how to control when a new page is added to a document or how to attach a template to the new page.
-
Mar 20th, 2002, 07:29 PM
#4
Addicted Member
OK. So your saying that you want VB6 to capture what Word is up to? I thought that you were completelly contolling the situation through VB6. In your case, It sounds like you are saying that Word is running on it's own and you want to intercept activities?
Perhaps, you need to write VB Script WITHIN WORD.
-
Mar 20th, 2002, 07:31 PM
#5
Fanatic Member
Either a script or a macro will do the job.
- If at first you dont succeed, then give up, cause you will never will!
-
Mar 21st, 2002, 12:23 AM
#6
Thread Starter
New Member
VB is controlling the word object and writing to the document. The output of several modules is writing to the document. This is a Computer Aided Process Planning application for manufacturing. It is a generative process not a variant.
-
Mar 21st, 2002, 12:55 AM
#7
Addicted Member
If Word is controlling the object, do you not already know when a new page is being added (afterall, you - VB - is doing it). And, if you know when your adding a page, can you not control the other necessary - the template?
-
Mar 21st, 2002, 12:16 PM
#8
Thread Starter
New Member
I can find no available object, method, or property that will allow me to control when a new page is added. The PageSetup object & PageSetup property is available but they do not give me the ability to control when a new page is added or define the template. Thanks for your replies.
-
Mar 21st, 2002, 02:44 PM
#9
Addicted Member
You are prolly deeper into the Word Automation than the rest of us.
Perhaps you can use RTF in VB than cause Word to import it when done?
-
Mar 22nd, 2002, 12:03 AM
#10
MS Word VBA does support a Pages collection. You can use this to work with pages in a document. If you just want to add to the end of the document, it would be easier to move the selection there then put in a page break. You can insert a template using the insert method (as long you don't have the template open and try to insert the same template--Word won't allow that type of recursive error). Here's the VBA code:
VB Code:
With Selection
.EndKey Unit:=6 'wdStory
.InsertBreak Type:=7 'wdPageBreak
.InsertFile FileName:="C:\My Documents\MyTemplate.dot", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
End With
-
Mar 22nd, 2002, 12:17 AM
#11
Oh yeah, you don't have to do that in VBA. Just use your wdObj or whatever before the statements (or put the whole thing in a with statement) or create an object, etc., etc. and you can do it from VB.
-
Mar 22nd, 2002, 12:22 AM
#12
Addicted Member
I thought I remembered that the Word object would do that!
:-
-
Mar 22nd, 2002, 12:20 PM
#13
Thread Starter
New Member
Thank you for the help! I appreciate it.
SurfsideRon
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
|