Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Word VBA
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2009, 11:24 PM
Registered User
 
Join Date: Sep 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Selecting a Word location from Excel

Hi,

I'd like to write a macro that opens a dialogue box in Word, which asks the user to choose a location in the document by clicking it, and for the code to either return the location of that selection, or just paste a bookmark to that location (and ask the user to name that bookmark).

I know that a similar thing can be done in Excel. Here is an example of an Excel macro that asks the user to select some cells in Excel, and then bold them:

Sub RangeDataType()
Dim rRange As Range
On Error Resume Next
Application.DisplayAlerts = False
Set rRange = Application.InputBox(Prompt:= _
"Please select a range with your Mouse to be bolded.", _
Title:="SPECIFY RANGE", Type:=8)
On Error GoTo 0
Application.DisplayAlerts = True
If rRange Is Nothing Then
Exit Sub
Else
rRange.Font.Bold = True
End If
End Sub

Unfortunately, Word's InputBox command doesn't seem to allow you to choose your range from Word. Is there another way of doing it?

Thanks,

Durand
 
Old September 9th, 2009, 11:41 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Just a thought

If input box is not allowing, you can create a modeless userform (like a input box) and get the location by selection.range.

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

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Location of Excel 2007 extracted files sektor Excel VBA 0 May 25th, 2009 07:59 AM
Selecting all cells of an excel sheet sanketaradhye Beginning VB 6 1 April 25th, 2007 02:26 AM
Re: Selecting a picture in MS Word VBA zainhansrod VB How-To 1 January 2nd, 2007 03:39 AM
selecting records from excel androoo Pro VB 6 1 January 12th, 2005 12:18 PM
Selecting multiple words in Word 2000 jdsturm98 Beginning VB 6 0 September 3rd, 2003 03:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.