Hints, tips and tricks for newbies
Moderators: Dorian (MJT support), JRL
-
yken
- Newbie
- Posts: 17
- Joined: Thu Jan 18, 2007 3:42 pm
- Location: Turkiye
Post
by yken » Sun Jun 12, 2016 4:11 pm
Hi,
I want to do like this macro with using Macro Scheduler.
for extend end of paragraph.
Code: Select all
Sub OfficeWordMacro1()
Selection.Extend Character:=ChrW(13)
End Sub
I tried like this but not work. Thanks for your help in advance.
Code: Select all
//Recorded Events
Let>WW_TIMEOUT=5
setfocus>PAPATYA.docx*
Wait>0.02
Press F8
Wait>0.02
send>Chrw(13)
Wait>0.02
-
hagchr
- Automation Wizard
- Posts: 331
- Joined: Mon Jul 05, 2010 7:53 am
- Location: Stockholm, Sweden
Post
by hagchr » Sun Jun 12, 2016 4:44 pm
Hi, do you want to select the whole paragraph or just from your current selection until the end of the paragraph?
-
yken
- Newbie
- Posts: 17
- Joined: Thu Jan 18, 2007 3:42 pm
- Location: Turkiye
Post
by yken » Sun Jun 12, 2016 4:52 pm
Hi,
Just from my current selection until the end of the paragraph.
-
hagchr
- Automation Wizard
- Posts: 331
- Joined: Mon Jul 05, 2010 7:53 am
- Location: Stockholm, Sweden
Post
by hagchr » Sun Jun 12, 2016 4:58 pm
Then something like this should do it:
SetFocus>Document3 - Microsoft Word
Wait>0.2
Press>CTRL
Press>Shift
Press>Down
Release>Shift
Release>CTRL
-
yken
- Newbie
- Posts: 17
- Joined: Thu Jan 18, 2007 3:42 pm
- Location: Turkiye
Post
by yken » Sun Jun 12, 2016 5:07 pm
Thank you. But it's not suitable in the "OutlineView" mod. This isn't work properly.
Alsao "press F8 *3" or "press F8 *4" aren't suitable. I'm working with headings "H3" view.
-
hagchr
- Automation Wizard
- Posts: 331
- Joined: Mon Jul 05, 2010 7:53 am
- Location: Stockholm, Sweden
Post
by hagchr » Sun Jun 12, 2016 5:21 pm
Have to think if a better way, but one way could be:
Code: Select all
SetFocus>Document1*
Wait>0.2
Press>CTRL
Press>ALT
SendText>p
Release>ALT
Release>CTRL
Wait>0.1
Press>CTRL
Press>Shift
Press>Down
Release>Shift
Release>CTRL
Wait>0.1
Press>CTRL
Press>ALT
SendText>o
Release>ALT
Release>CTRL
-
yken
- Newbie
- Posts: 17
- Joined: Thu Jan 18, 2007 3:42 pm
- Location: Turkiye
Post
by yken » Sun Jun 12, 2016 5:26 pm
Thank you very much.
-
hagchr
- Automation Wizard
- Posts: 331
- Joined: Mon Jul 05, 2010 7:53 am
- Location: Stockholm, Sweden
Post
by hagchr » Sun Jun 12, 2016 6:14 pm
Happy to help. It seems you don't have the same selection options when in outline view mode. I changed the code slightly so text will be selected if you press CTRL+e. To exit the script just press Escape. You can play/adjust so it suits you.
Code: Select all
OnEvent>KEY_DOWN,e,2,SRTExtend
OnEvent>KEY_DOWN,VK27,0,SRTExit
GetActiveWindow>docFocus,x,y
SetFocus>docFocus
Wait>0.1
Label>Main
Goto>Main
SRT>SRTExtend
Press>CTRL
Press>ALT
SendText>p
Release>ALT
Release>CTRL
Press>CTRL
Press>Shift
Press>Down
Release>Shift
Release>CTRL
Press>CTRL
Press>ALT
SendText>o
Release>ALT
Release>CTRL
END>SRTExtend
SRT>SRTExit
SetFocus>docFocus
Exit,code
END>SRTExit
-
yken
- Newbie
- Posts: 17
- Joined: Thu Jan 18, 2007 3:42 pm
- Location: Turkiye
Post
by yken » Mon Jun 13, 2016 12:59 pm
Sorry, I had to go out yesterday.
While "outline view 3" this combinations are selecting all remaining "h3" headings.
-
hagchr
- Automation Wizard
- Posts: 331
- Joined: Mon Jul 05, 2010 7:53 am
- Location: Stockholm, Sweden
Post
by hagchr » Mon Jun 13, 2016 1:38 pm
Hi, strange for me it seems to work but maybe depends on the text. I just had H3 paragraphs after each other when I tested. You have other text between the H3s? Which version of Word are you using?
I need to think a little about it. I also note that CTRL+e was not so good choice as that is used in Word for centering. It is better to choose a different shortcut, not used by Word.
-
yken
- Newbie
- Posts: 17
- Joined: Thu Jan 18, 2007 3:42 pm
- Location: Turkiye
Post
by yken » Mon Jun 13, 2016 1:46 pm
Word2007
Can we do this:
Code: Select all
Sub Mr1()
Selection.Extend Character:=ChrW(13)
End Sub
-
hagchr
- Automation Wizard
- Posts: 331
- Joined: Mon Jul 05, 2010 7:53 am
- Location: Stockholm, Sweden
Post
by hagchr » Mon Jun 13, 2016 7:18 pm
Hi, next try (sorry some soccer distractions in between). I used the command you mentioned - it belongs to the VB world so there needs to be a VBS section. I changed the trigger to CTRL+Shift+e for action and Esc for Exit. Try it and see if it works better or there are still issues.
Code: Select all
VBSTART
Dim wdApp, TestFlag
Sub FileIni()
TestFlag=False
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If wdApp Is Nothing Then
MsgBox("Open Word Document!")
TestFlag=True
End If
wdApp.Visible = True
End Sub
Sub Extend()
'If Outline View then change to normal view during selection extension, then back.
If wdApp.ActiveWindow.ActivePane.View.Type = 3 then
wdApp.Selection.Extend vbcr
Else
With wdApp
.ActiveWindow.ActivePane.View.Type = 3
.Selection.Extend vbcr
.ActiveWindow.ActivePane.View.Type = 2
End With
End if
End Sub
VBEND
GetActiveWindow>strWin,x,y
//CTRL+Shift+e will trigger action
OnEvent>KEY_DOWN,e,6,SRTMark
//Esc will trigger Exit
OnEvent>KEY_DOWN,VK27,0,SRTExit
//Initiate, attach to existing instance of Word
VBRun>FileIni
//If Word is not open then Exit
VBEval>TestFlag,TestFlag
If>TestFlag=True
Gosub>SRTExit
Endif
Label>Main
Wait>0.1
Goto>Main
SRT>SRTMark
//Turn onEvent off temporarily
OnEvent>KEY_DOWN,e,6,
wdApp.ScreenUpdating = False
VBRun>Extend
Wait>0.5
//Turn onEvent on again
wdApp.ScreenUpdating = True
OnEvent>KEY_DOWN,e,6,SRTMark
END>SRTMark
SRT>SRTExit
SetFocus>strWin
Exit>code
END>SRTExit
-
yken
- Newbie
- Posts: 17
- Joined: Thu Jan 18, 2007 3:42 pm
- Location: Turkiye
Post
by yken » Tue Jun 14, 2016 11:56 am
I've tried. That's it. Thank you very much.