|
-
Jul 13th, 2009, 05:20 AM
#1
Thread Starter
New Member
[RESOLVED] Editing word documents while keeping the original text.
Hello.
This problem is giving me a headache. I know its nooby. But how else will i learn?
Code:
Public objword As New Word.Application
objword.Documents.Open(FileName:=ofilename)
^ Showing the declaration of the word document that i wish to edit.
Code:
Dim oDoc As Word.Document
objword.Visible = True
oDoc = objword.ActiveDocument
oDoc.Range.Text = codes(j, 1) & " " & codes(j, 2)
This gets the document and adds text into it, exactly what i want it to do. But it replaces the whole document. I just want it to add text at the start of the document. Not replace the whole document.
Thanks, Schoolproject.
If there is any needed information. Don't hesitate to ask!
-
Jul 13th, 2009, 05:49 AM
#2
Re: Editing word documents while keeping the original text.
You don't define any range... So the range will be all the document.
VB.NET Code:
oDoc.Range.Text = codes(j, 1) & " " & codes(j, 2)
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Jul 13th, 2009, 06:03 AM
#3
Thread Starter
New Member
Re: Editing word documents while keeping the original text.
Yes thank you that did work, but when determining the range it deletes some characters from the beginning of the document.
For example, (this was my result in the word document)
Bill Smith COLLEGE
ADAMS STREET
....
Whereas i want it to say:
Bill Smith MATER DEI CATHOLIC COLLEGE
ADAMS STREET
.....
Its like typing when you have pressed the insert button or something..
-
Jul 13th, 2009, 06:51 AM
#4
Thread Starter
New Member
Re: Editing word documents while keeping the original text.
Wait thank you it worked after a bit of fiddling!
What finally worked was what you said thank you.
Code:
oDoc.Range(0, 0).Text = codes(j, 1) & " " & codes(j, 2)
Placing the range as 0,0 made it be placed at the beginning without taking any other text out.
Once again thank you.
School project
Tags for this Thread
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
|