Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-29-2015, 02:11 AM
anand anand is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Novice
move cursor
 
Join Date: Jun 2015
Posts: 15
anand is on a distinguished road
Default move cursor

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.
Reply With Quote
  #2  
Old 06-29-2015, 05:45 AM
gmayor's Avatar
gmayor gmayor is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 3,828
gmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to behold
Default

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
Reply With Quote
  #3  
Old 06-29-2015, 06:25 AM
anand anand is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Novice
move cursor
 
Join Date: Jun 2015
Posts: 15
anand is on a distinguished road
Default

It is a snaking column
Reply With Quote
  #4  
Old 06-30-2015, 02:08 AM
gmayor's Avatar
gmayor gmayor is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 3,828
gmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to behold
Default

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
Reply With Quote
  #5  
Old 07-05-2015, 03:09 PM
mrlemmer11 mrlemmer11 is offline move cursor Windows 7 32bit move cursor Office 2010 32bit
Novice
 
Join Date: Jun 2015
Posts: 13
mrlemmer11 is on a distinguished road
Default

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
Reply With Quote
  #6  
Old 07-05-2015, 03:19 PM
macropod's Avatar
macropod macropod is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,435
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #7  
Old 07-06-2015, 02:43 AM
anand anand is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Novice
move cursor
 
Join Date: Jun 2015
Posts: 15
anand is on a distinguished road
Default

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.
Reply With Quote
  #8  
Old 07-06-2015, 03:38 AM
macropod's Avatar
macropod macropod is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,435
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #9  
Old 07-06-2015, 03:50 AM
anand anand is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Novice
move cursor
 
Join Date: Jun 2015
Posts: 15
anand is on a distinguished road
Default

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
I am using this code to insert tab for statements that are using more than 1 line.It is working well for first column but not for snaking column. I have to insert tab for all statements that are using more than 1 line.

Last edited by macropod; 07-06-2015 at 04:03 AM. Reason: Added code tags & formatting
Reply With Quote
  #10  
Old 07-06-2015, 04:00 AM
macropod's Avatar
macropod macropod is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,435
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #11  
Old 07-06-2015, 08:55 PM
anand anand is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Novice
move cursor
 
Join Date: Jun 2015
Posts: 15
anand is on a distinguished road
Default

Can you please give me the code for paragraph indentation.It will help me a lot.
Reply With Quote
  #12  
Old 07-06-2015, 09:06 PM
macropod's Avatar
macropod macropod is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,435
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #13  
Old 07-06-2015, 10:39 PM
anand anand is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Novice
move cursor
 
Join Date: Jun 2015
Posts: 15
anand is on a distinguished road
Default

In this i have to add indentation to non numbered lines.
Attached Images
File Type: png a.png (12.0 KB, 12 views)
Reply With Quote
  #14  
Old 07-06-2015, 10:58 PM
macropod's Avatar
macropod macropod is offline move cursor Windows 7 64bit move cursor Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,435
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I asked for a document, not an image...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 07-07-2015, 05:57 AM
Charles Kenyon Charles Kenyon is offline move cursor Windows 8 move cursor Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 7,970
Charles Kenyon has much to be proud ofCharles Kenyon has much to be proud ofCharles Kenyon has much to be proud ofCharles Kenyon has much to be proud ofCharles Kenyon has much to be proud ofCharles Kenyon has much to be proud ofCharles Kenyon has much to be proud ofCharles Kenyon has much to be proud ofCharles Kenyon has much to be proud ofCharles Kenyon has much to be proud of
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
move cursor Put the cursor at the end of a comment 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

Other Forums: Access Forums

All times are GMT -7. The time now is 02:16 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2022 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft