Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

Cursor Position in Textcolumns

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ashish - 22 Feb 2005 14:31 GMT
Hi,

I have looked wherever I can but I just can't find a reliable way of
checking which textcolumn am I, in the code.
I have tried the Information(wdHorizontalPositionRelativeToPage),which
unforunately just about anywhere gives me a -1, no reason at all.
EVEN WHEN I HAVE ONLY A SINGLE LINE selected. 100% zoom in page view is the
default.
Next try has been the distancefromright and left in the hope of getting the
position wrt to the page end. No help again.

Is there a reliable way of knowing the current textcolumn of the
cell/range/row/selection/insertion point?

Ohh: I have 2 textcols, filled with a table. I am interating through the
rows. I need to do something specific for each row in the second text column.
I just can't triangulate the poistion. Each row may have a variable number of
cells.

Please help if someone has seen something like this.
Thanks.
Klaus Linke - 23 Feb 2005 02:03 GMT
Hi Ashish,

You can get it from the dialog:
Dialogs(wdDialogFormatColumns).ColumnNo

Would be nice if the ".Information" property would return it, too. Getting stuff from dialogs was the usual way to get information in old versions, but it's a dying art.

Greetings,
Klaus

"Ashish" <Ashish@discussions.microsoft.com> schrieb:
> Hi,
>
[quoted text clipped - 17 lines]
> Please help if someone has seen something like this.
> Thanks.
Ashish Dutt Sharma - 23 Feb 2005 04:43 GMT
Klaus,

Thanks for the tip. I am experimenting with it. However, is there a place
where they tell how does this work. Specifically, which dialogs property am I
retrieving? Reason for my question is this :
My document is all tables.
3-4 rows on top are single colum(Headers)
Then the main text of the doc is in the table populated inside the text col.
I am selecting the entire document. Now i need to do, lets say, process A
for the header rows, process B for the rows in first text col and C for the
one in second col.
Currently I'm iterating through all rows of all tables in the selection.
When I get to the rows in the textcols, I need to find what text col am I in
to apply B or C. My current loop actually is:

For Each myTable In Selection.Tables
       For Each myRow In myTable.Rows
           counter = counter + 1
           If counter < 4 Then GoTo NextRow
           If Dialogs(wdDialogFormatColumns).ColumnNo = 1 Then
               Call fixLeft(myRow.Range)
           Else
               Call fixRight(myRow.Range)
           End If
NextRow:
       Next
Next
End Sub

Basically, the first 4 rows have been taken care of already. Earlier I was
trying the Information property at the check point. But it was entirely
random replies.

> Hi Ashish,
>
[quoted text clipped - 28 lines]
> > Please help if someone has seen something like this.
> > Thanks.
Klaus Linke - 23 Feb 2005 04:54 GMT
Hi Ashish,

> However, is there a place where they tell how does this work.
> Specifically, which dialogs property am I retrieving?

The VBA help has a page on arguments of built-in dialogs.
You might find more info in the old Word95 WordBasic help file from
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=1A24B2A7
-31AE-4B7C-A377-45A8E2C70AB2


It's a bit of an anachronism to get information from the dialogs. It was the WordBasic way.
In some cases like this, you still need it, since VBA doesn't offer a way to get that info.

Not sure whether you're asking some question about your code...
It looks fine, except that you'd probably reset the counter to zero for each table?

Regards,
Klaus
Ashish Dutt Sharma - 23 Feb 2005 05:05 GMT
Thanks for the link. I acutally am discovering dialogs for the first time in
VBA. Am at msdn now. in the code sample that i've posted, since my selection
covers both the text columns, the dialog property is returning 1 always.
Atleast that's the reason why I think it's returning 1. However if i select
just one row from the second col, it returns 2 as expected.
That's why i was wondering do i have to set the scope of the DIalog somehow
to just the current row in the iteration? And if yes how?

> Hi Ashish,
>
[quoted text clipped - 13 lines]
> Regards,
> Klaus
Ashish Dutt Sharma - 23 Feb 2005 05:13 GMT
And oh.. I am (un?)fortunately doing this on a Windows 95 machine running
Word 97, all this running inside a Virtual Machine. DIdn't want to cplicate
the post, but since you indicated that I might have to use an older solution,
well yes, I am doing this on an OLD platform.
Klaus Linke - 23 Feb 2005 05:38 GMT
The version shouldn't be an issue.

But you have to actually selected the row (myRow.Select).
The dialog will return the column number of the current selection, and since your macro didn't use the selection at all, it always returned 1 (or whatever column the cursor happened to be in).

You can turn off screen updating (Application.ScreenUpdating = False) to avoid screen flicker ... it might speed up the macro a little bit, too.

Regards,
Klaus

> And oh.. I am (un?)fortunately doing this on a Windows 95 machine running
> Word 97, all this running inside a Virtual Machine. DIdn't want to cplicate
> the post, but since you indicated that I might have to use an older solution,
> well yes, I am doing this on an OLD platform.
Ashish Dutt Sharma - 23 Feb 2005 13:31 GMT
DID IT!
Thanks Klaus. Your pointer did it. I figured out the selected part on my
own. And backed up a copy of the range for further processing. Here's the
final code snippet for reference of anyone who may need it:

Set oriSelect = Selection.Range.Duplicate
For Each myTable In Selection.Tables
       For Each myRow In myTable.Rows
          myRow.Select
           
           If Dialogs(wdDialogFormatColumns).ColumnNo = 1 Then
               Call fixLeft(myRow.Range)
           Else
               Call fixRight(myRow.Range)
           End If
           
NextRow:
       Next
Next
---------------------------------------------------
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.