Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Word VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 12th, 2009, 08:46 AM
Authorized User
Points: 145, Level: 2
Points: 145, Level: 2 Points: 145, Level: 2 Points: 145, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2008
Location: India
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rangeshram
Default 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
Reply With Quote
  #2 (permalink)  
Old August 12th, 2009, 09:44 PM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

"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
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Reply With Quote
  #3 (permalink)  
Old August 13th, 2009, 09:39 AM
Authorized User
Points: 145, Level: 2
Points: 145, Level: 2 Points: 145, Level: 2 Points: 145, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2008
Location: India
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rangeshram
Default 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
Reply With Quote
  #4 (permalink)  
Old August 13th, 2009, 10:03 PM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

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
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Reply With Quote
  #5 (permalink)  
Old August 14th, 2009, 06:26 AM
Authorized User
Points: 145, Level: 2
Points: 145, Level: 2 Points: 145, Level: 2 Points: 145, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2008
Location: India
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rangeshram
Default 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
Reply With Quote
  #6 (permalink)  
Old August 14th, 2009, 07:58 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

In that case, when there are multiple instances of a bold word, are you selecting all instances?

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Reply With Quote
  #7 (permalink)  
Old August 14th, 2009, 08:39 AM
Authorized User
Points: 145, Level: 2
Points: 145, Level: 2 Points: 145, Level: 2 Points: 145, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2008
Location: India
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rangeshram
Default 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
Reply With Quote
  #8 (permalink)  
Old August 14th, 2009, 10:29 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

That sounds as a good option. Now what you want to do from here?

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Reply With Quote
  #9 (permalink)  
Old August 17th, 2009, 09:42 AM
Authorized User
Points: 145, Level: 2
Points: 145, Level: 2 Points: 145, Level: 2 Points: 145, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2008
Location: India
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rangeshram
Default

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
Reply With Quote
  #10 (permalink)  
Old August 17th, 2009, 09:48 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

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
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Display/Update Picture Chart Dynamically in Word Using VBA slbibs Word VBA 0 July 27th, 2009 01:36 PM
Dynamically add objects based on Word Bookmarks a4d2a0m VB How-To 2 February 27th, 2007 03:57 AM
assigning macros to word documents dynamically x_ray C# 0 May 30th, 2006 11:29 AM
Creating Table dynamically in Word Document ajish_jose Excel VBA 0 October 1st, 2003 12:11 AM



All times are GMT -4. The time now is 09:13 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.