|
-
Apr 16th, 2006, 06:02 PM
#1
Thread Starter
Lively Member
[RESOLVED] textboxes to a bookmark
I have a document and I was wondering was there a way that I could type text onto the document and it gets copied into the text box i have created at real time. Thanks
Last edited by Hack; Apr 20th, 2006 at 08:16 AM.
Reason: Added [RESOLVED] to thread title and green "resolved" checkmark
-
Apr 19th, 2006, 08:33 AM
#2
Re: Document - TextBox
well the closest I could get was this:
I cant find a "Keypress" event.... will keep looking though
VB Code:
Dim WithEvents WDoc As Word.Application
Private Sub Form_Load()
Dim wrd As New Word.Application
wrd.Documents.Add
Set WDoc = wrd.Application
WDoc.Visible = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
WDoc.Quit
End Sub
Private Sub WDoc_WindowSelectionChange(ByVal Sel As Word.Selection)
Text1 = Sel
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 19th, 2006, 11:29 AM
#3
Thread Starter
Lively Member
Re: Document - TextBox
Well i am now trying to copy text entered into the textbox and put it into the bookmark. I can get it working partially but it says it inserts before and is a pain. Is there anyway I can get it just to copy the normal text.
VB Code:
Private Sub Document_New()
End Sub
Private Sub TextBox1_Change()
With ActiveDocument
.Bookmarks("test1").range.InsertBefore TextBox1.Text
End With
End Sub
Last edited by caz1805; Apr 19th, 2006 at 11:36 AM.
-
Apr 19th, 2006, 11:55 AM
#4
Re: textboxes to a bookmark
.Type
SOrry.. word is not my strong suit as far as Office goes...
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 19th, 2006, 11:57 AM
#5
Thread Starter
Lively Member
Re: textboxes to a bookmark
what do you mean with .type?
I tried it instead of .Insertbefore but it created an error.
thanks alot static.
caz
-
Apr 19th, 2006, 12:21 PM
#6
Re: textboxes to a bookmark
wasnt sure...
I know when u record a macro in word and type some words.. it used blah.blah.type "words etc" or something like that.. worth a shot sorry
try recording a macro.... and then look at the code (ALT+F11)
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 19th, 2006, 12:28 PM
#7
Thread Starter
Lively Member
Re: textboxes to a bookmark
yeh i could try that but still got to make the link between the textbox and the bookmark which i can tdo without vba. Thanks anyway mate.
Here is the code i have just got but with the same errors for some reason and underneath is the output.
VB Code:
Private Sub TextBox1_Change()
With ActiveDocument
.Bookmarks("test1").range.Text = TextBox1.Text
End With
End Sub
Input in textbox: hello
Ouput at bookmark: hellohellhelheh
caz
Last edited by caz1805; Apr 19th, 2006 at 01:08 PM.
-
Apr 19th, 2006, 02:20 PM
#8
Lively Member
Re: textboxes to a bookmark
The problem here is that the change event will fire off everytime you make a change so you type "h", bookmark = "h", you then type "e" so you have "he" in your text box, which again is added to the bookmark giving you "heh" and so on.
Not sure how you will get round this, but I'm sure someone can offer you some direction. Maybe you can fire the event with a keypress or a command button instead?
Last edited by New2vba; Apr 19th, 2006 at 02:29 PM.
"Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )
-
Apr 19th, 2006, 02:29 PM
#9
Thread Starter
Lively Member
Re: textboxes to a bookmark
Thanks New2VBA, yeh that figures now. Making it on a vbKeySPace still had the problem with updating everything in the textbox.
Do you know anyway of using autocorrect in a document and showing both the old text and the changed text at the same time.
thanks for that.
caz
-
Apr 19th, 2006, 02:33 PM
#10
Lively Member
Re: textboxes to a bookmark
Sorry I don't, although if you search autocorrect in vba help there seems to be quite a lot of information, including examples.
"Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )
-
Apr 19th, 2006, 02:34 PM
#11
Thread Starter
Lively Member
Re: textboxes to a bookmark
DO you think i could send info from a bookmark into a textbox?
caz
-
Apr 19th, 2006, 07:34 PM
#12
Thread Starter
Lively Member
Re: textboxes to a bookmark
solved thanks for all the help
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
|