I'm trying to make a macro that changes all comment text to left-to-right text. I can do this manually (create comment, change style to automatically update, then apply LTR) but the macro I record doesn't make the change. Indeed, in Word 2003 it doesn't even work while I'm recording the macro.
Here's the code in Word 2003:
Code:
Selection.Comments.Add Range:=Selection.Range
With ActiveDocument.Styles("Comment Text")
.AutomaticallyUpdate = True
.BaseStyle = "Normal"
.NextParagraphStyle = "Comment Text"
End With
Selection.LtrPara
With ActiveDocument.Styles("Comment Text")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "Comment Text"
End With
WordBasic.RejectChangesSelected
It doesn't work in Word 2007 either. The code (below) seems to basically boil down to
Strange, it not only lets me edit the text but is also left aligned. Please see snapshot.
Code I used
Code:
Sub Sample()
Selection.Comments.Add Range:=Selection.Range
With ActiveDocument.Styles("Comment Text")
.AutomaticallyUpdate = True
.BaseStyle = "Normal"
.NextParagraphStyle = "Comment Text"
End With
Selection.LtrPara
With ActiveDocument.Styles("Comment Text")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "Comment Text"
End With
End Sub
SNAPSHOT
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Yes, same here: the comment is still right-to-left. But if you carry out the steps manually, it (and all subsequent) comments will be left-to-right:
1. Create new comment (Insert > Comment)
2. Modify comment style to automatically update (Format > Styles and formatting > down arrow next to Comment Text > Modify... > check Automatically update box > OK)
3. Format paragraph left-to-right (need to first assign button/key combination to LtrPara: Tools > Customize > Categories: All Commands > Commands: drag LtrPara to toolbar)
4. Turn off automatically update for Comment Text style
5. Delete comment
BTW, the reason why I need to do this is that I get a lot of English documents that were created on Arabic-language computers. The main text is not a problem, but writing English comments in RTL mixes up the word order.
me too, i get an empty document when i open your attachment, no code, no text
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
i must have missed the point of posting an empty document to type something into
a sample document, that demonstrates the problem, would have to of been of more value
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
levydav, I tested it manually as well as with the code but the comment is pretty much readable. Please see this sncreenshot.
I agree that when you manually type then the words are in reverse order but after typing, if you pause for a moment, the words are automatically rearranged.
Screenshot
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Try typing a longer sentence, then making a change in the middle of it - it starts to behave strangely and in a way you wouldn't want to deal with if you were writing a hundred comments. This is a regular headache for our editors when working with English documents that were created on Arabic-language computers.
However, doing these steps manually should fix the problem; but the macro doesn't behave the same as manually...
The following steps will make all new comments left-to-right:
1. Create new comment (Insert > Comment)
2. Modify comment style to automatically update (Format > Styles and formatting > down arrow next to Comment Text > Modify... > check Automatically update box > OK)
3. Format paragraph left-to-right (need to first assign button/key combination to LtrPara: Tools > Customize > Categories: All Commands > Commands: drag LtrPara to toolbar)
4. Turn off automatically update for Comment Text style
5. Delete comment
Why not create a user form which accepts input for comment in a multiline textbox and this userform can be called by a shortcut key? That way the users can type very comfortably in the userform's textbox and when they are done, the update button will update the comment? let me know if you want to see an example?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Interesting solution. I think at this point, though, I'd rather just do these steps once by hand before handing articles over to the editor. I was just hoping that these steps could be included in the preparation macro that we run on all papers before giving to editors. - Thanks