|
-
Mar 14th, 2009, 02:22 PM
#1
Thread Starter
Member
[RESOLVED] Write text to textfield in word
I have a .dot file with a textfield (not a part of a form) in the pageheader. I can select the pageheader but don't know how to select the textfiels.
Also when i have a bookmark in this textfield, i can't use this from te main document.
Can someone help me with this?
Dim oWord = New Word.Application
oWord.Visible = True
Dim oDoc As New Word.Document
oDoc = oWord.Documents.Add("C:\Documents and Settings\Andy\Bureaublad\Brief.dot")
'first lets get to the header of the document
oDoc.Content.Application.ActiveWindow.ActivePane.View.SeekView = CInt(Word.WdSeekView.wdSeekCurrentPageHeader)
-
Mar 17th, 2009, 10:35 AM
#2
Hyperactive Member
Re: Write text to textfield in word
I cant help you but what will I do wenn I try to do similar things in automating word:
1. start recording a macro in word
2. do whatever I have to do (in your case I will: eneter with cursor in field, enter text in Field, exit field)
3. Stop recording macro
4. See VBA code that Word has created auitomaticaly
5. Study it, and transform it to VB code
That VBA code is very similar to VB code that you need 
Hope it helped
-
Mar 17th, 2009, 01:54 PM
#3
Thread Starter
Member
Re: Write text to textfield in word
It's not that easy. When i was recording the macro i couldn't select first my pageheader and second the text shape in that header. I couldn't use my mouse to help me.
But with a lot of trying in vb.net i allready found the sollution.
-
Mar 17th, 2009, 02:11 PM
#4
Re: Write text to textfield in word
Hello,
If you have found a solution to your problem remember to share with the community.
Can you post what you did to resolve your problem?
Gary
-
Mar 17th, 2009, 02:41 PM
#5
Thread Starter
Member
Re: Write text to textfield in word
Yes, no problem.
Dim objWord As New Word.Application
Dim objDoc As New Word.Document
With objWord
objWord.Visible = False
objDoc = objWord.Documents.Open(Application.StartupPath & "\template.dot")
objDoc.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Shapes.Item(2).TextFram e.TextRange.Select()
.Selection.Font.Underline = Word.WdUnderline.wdUnderlineNone
.Selection.Font.Name = "Tahoma"
.Selection.Font.Size = 8
.Selection.Font.Color = 6976647
.Selection.TypeText(Text:="This is a test:" & vbCrLf)
............
I hope this will help other people because it was hard to find on google .
-
Mar 17th, 2009, 02:45 PM
#6
Re: Write text to textfield in word
Thanks!!
Like you say, hopefully this will help people in the future.
To make things easier, you might want to mark your thread as resolved, and then also use the new tagging feature that is available on the threads, following the upgrade last night. This will help if people are searching for a particular tag. You can find more information about the new features here:
http://www.vbforums.com/showthread.php?t=561973
Gary
-
Mar 17th, 2009, 02:59 PM
#7
Thread Starter
Member
Re: Write text to textfield in word
I added 5 tags.
I don't find where i can select this thread as resolved.
-
Mar 17th, 2009, 03:09 PM
#8
Re: Write text to textfield in word
have a look in my signature, there is a link in there explaining how to do that.
Gary
-
Mar 17th, 2009, 03:14 PM
#9
Thread Starter
Member
Re: Write text to textfield in word
Doens't work.
Invalid FAQ Item specified. If you followed a valid link, please notify the administrator.
But i found it. It's the green V-mark.
-
Mar 17th, 2009, 03:23 PM
#10
Re: Write text to textfield in word
Hey,
I have updated the link in my signature.
What you have done is not setting the thread as resolved 
Gary
-
Mar 17th, 2009, 04:51 PM
#11
Thread Starter
Member
Re: [RESOLVED] Write text to textfield in word
Was een poging waard .
Heb het gevonde, bedankt.
-
Mar 18th, 2009, 01:51 AM
#12
Re: [RESOLVED] Write text to textfield in word
No idea what you just said (I am hoping it was good )
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
|