![]() |
|
#1
|
|||
|
|||
![]() High! I'm trying to write a simple macro to just select the current paragraph, but with no success. Can anyone help? Thanks! |
#2
|
|||
|
|||
![]()
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey Selection.Paragraphs(1).Range.Select lbl_Exit: Exit Sub End Sub |
#3
|
||||
|
||||
![]()
Why would you want a macro for that? Simply triple-clicking on a paragraph will select it.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
![]()
Many thanks, gmaxey and thank you macropod for replying!
The line: Selection.Paragraphs(1).Range.Select is just what I needed. I will insert it into a large macro. |
#5
|
||||
|
||||
![]()
With VBA, it is rare that anything needs to be selected. Using selections is inefficient, prone to producing screen flicker, and typically leads to the insertion point ending up somewhere completely different from where you started out.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
![]()
Thanks again, macropod! I need to select a paragraph in oder to format it with a specific language. Is there a way to do it without selecting the paragraph? Cheers!
|
#7
|
||||
|
||||
![]()
Since you haven't posted the code of which this is part, all I can work with is the initial Selection, for which you could use something like:
Selection.Paragraphs(1).Range.LanguageID = wdBelgianFrench But even that initial Selection is most likely unnecessary.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#8
|
|||
|
|||
![]()
Thanks, macropod! Your code line doesn't work. How would you do the trick with Range? All the best!
|
#9
|
||||
|
||||
![]()
It works for me. You can demonstrate it with something as simple as:
Code:
Sub Test() MsgBox Selection.Paragraphs(1).Range.LanguageID Selection.Paragraphs(1).Range.LanguageID = wdBelgianFrench MsgBox Selection.Paragraphs(1).Range.LanguageID End Sub Without seeing your code, it's impossible to say how it should be revised.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
|||
|
|||
![]()
High, macropod! I do apologize: your code really works. I can't understand why it didn't the first time I tried it. Many thanks and all the best!
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inserting a tab char at the end of current paragraph | RRB | Word VBA | 5 | 03-14-2024 01:49 PM |
![]() |
Aengus345 | Word VBA | 3 | 02-12-2024 06:28 AM |
A macro that moves the current paragraph up or down? | New Daddy | Word VBA | 2 | 04-13-2014 02:25 PM |
![]() |
Jo-NathanBSChE | Excel | 1 | 04-16-2013 03:10 AM |
![]() |
Jennifer Murphy | Word VBA | 9 | 01-29-2012 06:50 PM |