![]() |
|
#1
|
|||
|
|||
![]() I need VBA code in word to move cursor to starting of document of second column...means the page is divided into 2 columns and I have to traverse entire data of second column. |
#2
|
||||
|
||||
![]()
What sort of 'column'? Is this a table or snaking columns?
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
It is a snaking column
|
#4
|
||||
|
||||
![]()
Hmmm. I was afraid of that. As far as I am aware Word does not make the column available as an entity to Word VBA. It is simply part of the text flow, so I can think of no way to access the top of a particular column. Being part of the text flow the location is also variable.
Is there any other way you can identify the text you wish to access? What exactly is the nature of the task you are trying to achieve?
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
![]()
I know it's not too terribly dynamic, but if the first column will always be static and not change its contents, then you could just use:
Selection.Start = 3729 Where 3729 = the first character of the second column... however, once again, if column 1's character count increases by 20 lets say then your selection.start would also need to increase by 20 |
#6
|
||||
|
||||
![]()
You could use code like:
Code:
Dim Rng As Range Set Rng = ActiveDocument.ActiveWindow.Panes(1).Pages(1).Rectangles(2).Range
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
![]()
These are not working for my code.
I have to run loop in second column as i am doing for first column.my present code is working for first column only, not for second column. |
#8
|
||||
|
||||
![]()
Since you haven't posted any code, you can't expect much help in diagnosing any issues you might be having. Simply saying "These are not working for my code" is meaningless without a context.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
![]() Code:
Sub a() Dim orng As Word.Range Selection.HomeKey Unit:=wdStory Do Selection.EndKey Unit:=wdLine If Selection.End >= ActiveDocument.Content.End - 1 Then Exit Do End If Set orng = ActiveDocument.Bookmarks("\Line").Range With orng .Collapse wdCollapseStart .MoveEnd wdCharacter, 1 .Select ans = IsNumeric(orng) If orng.Font.Bold = False And ans = False Then Selection.HomeKey Unit:=wdLine Selection.TypeText Text:=vbTab End If 'Do something with oRng End With Selection.MoveDown Unit:=wdLine Loop lbl_Exit: Exit Sub End Sub Last edited by macropod; 07-06-2015 at 04:03 AM. Reason: Added code tags & formatting |
#10
|
||||
|
||||
![]()
Why on earth are you using tabs instead of paragraph indents? Inserting tabs makes future edits a nightmare. Furthermore, even if tabs are required, there is no need to select anything; nor do you need to know anything about how many columns there are on the page.
Finally, there is nothing in your code to indicate you've made even the slightest attempt to integrate the code in post #6 with what you're doing. PS: When posting code, please use the code tags, indicated by the # button on the posting menu.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
![]()
Can you please give me the code for paragraph indentation.It will help me a lot.
|
#12
|
||||
|
||||
![]()
If you attach a sample document to a post, showing what you want indented, plus an example of what the end result should look like, I or one of the other contributors here could probably help.
You can attach a document to a post via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#13
|
|||
|
|||
![]()
In this i have to add indentation to non numbered lines.
|
#14
|
||||
|
||||
![]()
I asked for a document, not an image...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#15
|
|||
|
|||
![]()
Paul is trying hard to help. I would just add that adding tabs in the middle of a paragraph instead of using indents is especially problematic. The difference is that a tab is a character while indents are formatting. I assume that you want the non-numbered lines to be indented to be even with the text following the number rather than with the number. This is done using a hanging indent. You would want to accomplish this modifying the paragraph Style. There is no need to be doing this through vba.
Basic Concepts of Microsoft Word - from Shauna Kelly |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
mrlemmer11 | Word VBA | 1 | 06-25-2015 09:56 AM |
How do I move the cursor back to the text from a comment without using the mouse? | MsT | Word | 2 | 04-24-2014 05:48 PM |
cursor madness | jamesschot | Word | 0 | 02-18-2010 07:32 AM |
cursor disappears | ehamike | Word | 0 | 04-03-2009 07:56 PM |
can't move the cursor in Word | pieboy | Word | 2 | 02-13-2009 07:15 PM |