Simple begginers ? - Add text to a blank document 
Author Message
 Simple begginers ? - Add text to a blank document

Hi,

I am able to create a word document with the following code.

What I am struggling to do, is open up a specific template, and then just
add some basic words to it. I have been able to have bookmarks work, but I
need to use another method, as the bookmarks may not exisit in the end
document.

How do I just put text in the new document ?

--------------
Dim oWord As Word.Application

Dim oDoc As Word.Document

oWord = CreateObject("Word.Application")

oWord.Visible = True



Mon, 05 Dec 2005 20:10:35 GMT  
 Simple begginers ? - Add text to a blank document
Hi Waldo

Create a template that has bookmarks in it at the locations where you want
to insert the information and then create a new document from the template
and insert the data as follows:

Dim oWord As Word.Application
Dim oDoc As Word.Document

Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add("Yourtemplate")
oWord.Visible = True
oDoc.Bookmarks("Test1").Range.InsertBefore "YourText"

Don't forget to Set oDoc and OWord to nothing when you have finished
whatever else it is that you are doing.

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP

Quote:
> Hi,

> I am able to create a word document with the following code.

> What I am struggling to do, is open up a specific template, and then just
> add some basic words to it. I have been able to have bookmarks work, but I
> need to use another method, as the bookmarks may not exisit in the end
> document.

> How do I just put text in the new document ?

> --------------
> Dim oWord As Word.Application

> Dim oDoc As Word.Document

> oWord = CreateObject("Word.Application")

> oWord.Visible = True



Mon, 05 Dec 2005 20:45:11 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Adding a directory full of pictures to a blank document

2. Disabling document blank space before close document

3. VBA code adding 6 blank lines after adding pragraphs - Word 97

4. another begginer (shit) add mouse move to combobox

5. Cannot add FileSaveDialog to simple text editor

6. Adding text to a document without opening it.

7. Adding text to not active word document

8. Begginer needs some help with text files

9. Trying to append a simple XML document as a node in an XML document

10. Blank space at beginning of paragraph when Text Interpretation is set to HTML Text

11. Blank Simple VBscript

12. How to add a document to another document

 

 
Powered by phpBB® Forum Software