|
|
 |
| Word VBA Discuss using VBA to program Word. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Word VBA section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

August 12th, 2009, 08:46 AM
|
|
Authorized User
|
|
Join Date: May 2008
Location: Chennai, Tamil nadu, India.
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
VBA Word Userform Dynamically - Help
Dear all,
Pls. help me to find the solution for Dynamic Positions in word.
I have created form with Listbox control to show the bold text in the whole document.
While selecting/double click the listbox item in the userform, the cursor will automatically go to their respective positions.
For example: Let us assume below instances were in the listbox
TextBold1
TextBold2
TextBold3
By clicking the TextBold2 i.e., the selected word in the listbox will match the word document and the cursor will automatically pointed there.
Code:
UsrfrmMain.lstBold.AddItem strBold(i)
UsrfrmMain.Show
I need help for the placing dynamic positions while clicking the listbox in the userform.
Thanks,
Rangesh
|

August 12th, 2009, 09:44 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 420
Thanks: 0
Thanked 14 Times in 14 Posts
|
|
"By clicking the TextBold2 i.e., the selected word in the listbox will match the word document and the cursor will automatically pointed there.
"
Do you want the click to take you to the position TextBold2?
If that is the case, you need to place some bookmarks in the document when you are loading them to the userform's listbox. The bookmarks should have the prefix similar to the textprefixes. This might be in the Userform_Initialize event
For example, TextBold1 will have BookMK1, TextBold2 will BookMK2 and so on
Then in the click event of the listbox you can use the following
Selection.GoTo what:=wdGoToBookmark, Name:="BookMK" & listbox1.listindex
You can delete/clear those bookmarks in userform's terminate event if needed
Cheers
Shasur
|

August 13th, 2009, 09:39 AM
|
|
Authorized User
|
|
Join Date: May 2008
Location: Chennai, Tamil nadu, India.
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
VBA Word Userform Dynamically - Help
Thanks Shasur for your reply.
I am eager to know is there any other alternative method to create dynamic position other than bookmarks. The reason was i've to create more than thousands of bookmarks because the document content was approximately 600 pages per document.
And also our client was not happy with using bookmarks. It would be highly appreciated if we get some other option...
Thanks,
Rangesh
|

August 13th, 2009, 10:03 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 420
Thanks: 0
Thanked 14 Times in 14 Posts
|
|
Hi Rangesh
Bookmarks are the foolproof method and it will look really dynamic with the listbox_change/click event.
Can you tell the way you are loading the boldtext with the userform. Are you loading the boldtext of entire document or section by section?
Cheers
Shasur
|

August 14th, 2009, 06:26 AM
|
|
Authorized User
|
|
Join Date: May 2008
Location: Chennai, Tamil nadu, India.
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
VBA Word Userform Dynamically - Help
Hi Shasur,
We're finding all the bold instances in the whole word document and stored in array with unique instances only.
Then load the array content in the lstbold.addItem control by clicking the listed item in the listcontrl the cursor will point to the selected item in the word document.
Hope is this clear...
Thanks,
Rangesh
|

August 14th, 2009, 07:58 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 420
Thanks: 0
Thanked 14 Times in 14 Posts
|
|
In that case, when there are multiple instances of a bold word, are you selecting all instances?
Cheers
Shasur
|

August 14th, 2009, 08:39 AM
|
|
Authorized User
|
|
Join Date: May 2008
Location: Chennai, Tamil nadu, India.
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
VBA Word Userform Dynamically - Help
Yes you're correct. The listitem will show all the instances with unique words and when clicking the particular item in the listbox it works as find option in word with forward option true.
Thanks,
Rangesh
|

August 14th, 2009, 10:29 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 420
Thanks: 0
Thanked 14 Times in 14 Posts
|
|
That sounds as a good option. Now what you want to do from here?
Cheers
Shasur
|

August 17th, 2009, 09:42 AM
|
|
Authorized User
|
|
Join Date: May 2008
Location: Chennai, Tamil nadu, India.
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
From the listed bold occurrences in the userform, when the user click the listitem it will goto that word(places) and the user can change the instances to unbold if necessary.
Hope the objective of this project is clear..
Thanks,
Rangesh
|

August 17th, 2009, 09:48 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 420
Thanks: 0
Thanked 14 Times in 14 Posts
|
|
If that is the case, your forward option will be a great one right? User uses the forward button to select the bold-face word and change it if necessary.
If that has to do with any copy-editing kind of stuff, then the editor needs to read the context and make changes, which I think is best with your 'forward' option
Cheers
Shasur
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |