•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Windows NT / 2000 / XP / 2003 section within the Tech Talk category of DaniWeb, a massive community of 391,556 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,661 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Windows NT / 2000 / XP / 2003 advertiser:
Views: 5839 | Replies: 2
![]() |
•
•
Join Date: Jul 2003
Posts: 22
Reputation:
Rep Power: 6
Solved Threads: 0
I have a document that needs to be filled out. To help the user input all the correct information that goes on the form, I built a user form. On enter, the information gets transferred to the form. To accomplish this I use this statements like the ones below:
ActiveDocument.Bookmarks("NAME").range.InsertBefore txtName
ActiveDocument.Bookmarks("ADDRESS").range.InsertBefore txtAddress
This works great because I have separate bookmarks for Name and Address. But, what if I just have one bookmarks called "DATA":
ActiveDocument.Bookmarks("DATA").range.InsertBefore txtNetWeight _
& vbTab & txtCostPerLbs & vbCrLf
After this gets put on the document, I ask the users if he needs to input data again. If he clicks on Yes, then:
ActiveDocument.Bookmarks("DATA").range.InsertBefore txtNetWeight _
& vbTab & txtCostPerLbs & vbCrLf
BUT, here's the problem. I need the second set of data to be inserted below the first line that is already on the document. What happens instead is that it gets inserted above the line that is already on the document.
Any ideas? :roll:
ActiveDocument.Bookmarks("NAME").range.InsertBefore txtName
ActiveDocument.Bookmarks("ADDRESS").range.InsertBefore txtAddress
This works great because I have separate bookmarks for Name and Address. But, what if I just have one bookmarks called "DATA":
ActiveDocument.Bookmarks("DATA").range.InsertBefore txtNetWeight _
& vbTab & txtCostPerLbs & vbCrLf
After this gets put on the document, I ask the users if he needs to input data again. If he clicks on Yes, then:
ActiveDocument.Bookmarks("DATA").range.InsertBefore txtNetWeight _
& vbTab & txtCostPerLbs & vbCrLf
BUT, here's the problem. I need the second set of data to be inserted below the first line that is already on the document. What happens instead is that it gets inserted above the line that is already on the document.
Any ideas? :roll:
Well, I'm a VB.NET developer, and I don't really know much about VBA with MS Word, but, why not try creating a new bookmark at the end of your inserted portion, and then insert at that new bookmark?
You could then have an unlimited amount of inserts without a problem.
You could then have an unlimited amount of inserts without a problem.
-Ryan Hoffman
ASP.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
ASP.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
•
•
Join Date: Jul 2003
Posts: 22
Reputation:
Rep Power: 6
Solved Threads: 0
Thanks for the reply. I actually received some help yesterday from a different source, Martin Green's Office Tips, and my problem is now solved. You were correct in your suggestion. Here's what Mr. Green suggested:
Dim DataRange As Range
Set DataRange = ActiveDocument.Bookmarks("Data").Range
If DataRange = "" Then
DataRange = "Some Text"
Else
DataRange = DataRange & " " & "More Text"
End If
ActiveDocument.Bookmarks.Add "Data", DataRange
Where I have written "Some Text" and "More Text" you can substitute with you textbox names. My example puts a space between the insertions. You could puta line break instead:
DataRange = DataRange & vbCrLf & "More Text"
I think that would work
Dim DataRange As Range
Set DataRange = ActiveDocument.Bookmarks("Data").Range
If DataRange = "" Then
DataRange = "Some Text"
Else
DataRange = DataRange & " " & "More Text"
End If
ActiveDocument.Bookmarks.Add "Data", DataRange
Where I have written "Some Text" and "More Text" you can substitute with you textbox names. My example puts a space between the insertions. You could puta line break instead:
DataRange = DataRange & vbCrLf & "More Text"
I think that would work
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Windows NT / 2000 / XP / 2003 Marketplace
•
•
•
•
apple browser cd choose command computer console crack debian defender dell development download drm explorer fiji install internet leopard linux microsoft mobile news office open operating os parliament photo registry root security server software source spyware survey system technology tiger torvalds tweaks ubuntu unix upgrade vista windows windows update windows vista xp
- Visual Basic 4 Upgrades? (Visual Basic 4 / 5 / 6)
- DDE Poke - Stay minimized (Visual Basic 4 / 5 / 6)
- Macros & VB to create various letters (Visual Basic 4 / 5 / 6)
- PLease rate/review my resume (IT Careers and Business)
- isdesign.ocx and mscomct2.ocx (Visual Basic 4 / 5 / 6)
Other Threads in the Windows NT / 2000 / XP / 2003 Forum
- Previous Thread: New Hardware Causing Error
- Next Thread: How To Tweak Icon Sizes and so,Windows XP Startbar


Linear Mode