Determining Left and Right Table Boundary Position - vba

I need to know the left and right boundary position of a table. I tried various combinations of Selection.Information(wdHorizontalPositionRelativeToPage), but that appears to give the position of text within the table, and hence is dependent on cell padding and left/center/right justification.
I want the left and right table border position.
It seems this should be simple. For instance, the table knows where to draw it's boundaries.

You need to get the position of the table's range not the selection.
ActiveDocument.Tables(n).Range.Information(wdHorizontalPositionRelativeToPage) will give you the position for a specific table.
Selection.Tables(1).Range.Information(wdHorizontalPositionRelativeToPage) will give you the position for the table that contains the selection.

Related

Left and Top positions of table cells relative to page in MS Word

I need to calculate the left and top coordinates of a table cell.
At work we have been developing an Add-In in VBA for Microsoft Word to turn Word documents into fillable PDF forms. All fields are to be inserted inside table cells, so it is the exact location of the table cells (left and top relative to the page) that are necessary for the placing of the data fields.
To get the vertical position of the top of a cell relative to the upper leftmost corner of the page we have tried:
Tables(n).Cell(row,column).Range.Information(wdVerticalPositionRelativeToPage)
The results exceed the table Top position by about 5 points at the top of the page. The excess is reduced as you go down the page. In cells located about the end of the page the result is spot on.
To get the horizontal position relative to the upper leftmost corner of the page we have tried:
Tables(n).Cell(row,column).Range.Information(wdHorizontalPositionRelativeToPage)
The results are incorrect. The results point to Left of the Table (not of the cell) plus about 3 points.
We have tried setting the table to Fixed Column Widths, and varying the zoom from 100% to fit to Window. No luck.
Any suggestions how to get the correct vertical (top) and horizontal (left) positions of a cell?

How to keep Reporting services table in the same page

Is it possible to keep table column within the same page? It always go to the new page when table width is larger than page.
I design a report with TableA that have dynamic columns. The dynamic columns are in short format. For example: BS, BN, OT...
In order to understand column meaning, I have to create another table, TableB, below the table to explain. I want to display it horizontally. For example: BS: Basic Salary| BN: Bonus| OT: Over Time| ...
But when TableB has many columns, It go to new page and leave a lot of blank space in previous page. I want to keep columns in the same page, if possible.
I want TableB to display like this:
|X:xx| X:xx | X:xx| X:xx| (Edge of right page)
|X:xx| X:xx|
You're using a horizontal table, a great tutorial is described here
You probably have most of the horizontal table figured out, just this part is important to your issue.
Step 4
Right-click on the column header and select "Edit Group". Enter this
for the group expression: =RowNumber(Nothing). This will cause the
matrix to give you one column per row of data. Since horizontal tables
can end up rather wide, you probably want your table wrap around to
the next "line" after a specific number of columns.
Just simply count the number of rows that fit your page exactly and define this number in your column group expression as described in the tutorial.
Use Column Visibility to hide column instead of Cell Visibility. This should eliminate the blank space.
If the report is still too big, set the report interactive size to 0in,0in. This will keep everything in one page.

Is it possible to set vb.net datagridview cell alignment without modifying whole column?

I am trying to set the alignment of a specific cell in a row/column to be right aligned. However I do not want to set the whole row, or whole column to right aligned. Is it possible to set the cell only? From what I've seen online I'm starting to think it isn't possible.
You would need to hook up to the RowDataBound event. This fires as each row is databound. Check that the row is a data row (as opposed to a header or footer). Then check the value in the column you are interested in. If the value meets your criteria for right justification then apply that to the column in question.
Note if you are using AlternateItemTemplate then check both Item rows and AlternateItem rows.
I've used this method to say change the backround colour of values that fall outside a range.

How to make rows invisible while printing reports?

I am using an .rldc file to define the layout of the reports from my program. The problem is, it is to be used for incremental printing. That means the paper will be used over and over as newer rows need to be printed. I'm attempting to approach it this way:
List all corresponding data on the report view.
Make the older rows invisible and only show the latest row.
Print.
That way, the last row is already properly placed. The problem is, I don't know how to implement this. Can anyone help me out?
You could create an IIF(condition,true,false) statement in your report definition on the row visibility variable.
The best way i guess is to define in your data source something of a rank column.
example :
select col1,col2,col3,RANK() OVER (ORDER BY col3 DESC) AS 'rank' from table1
Then in your table or matrix, you click on the row or/and column that you want to make the borders and text white based on a expression.
Go to the properties and dropdown on bordercolor
choose expression and type in (based on my example query)
=IIf(rank.value <> max(rank.value),White,Black)
That will not remove the rows only make the borders white ( unvisible)
The same you can do with Font Color property.
I think this is your best shot at this issue.
Other solution I could think of is to just hide unneccesary rows (which also replaces the visible row)
Then to move the table down by using a expression with a formula like nr of rows hidden before the actual row * height of 1 row, only I m not sure if this is applicable without programming an RDL extension..
Good Luck !

Getting position of pdfptable

in my document I am creating 3-4 pdfptables.
At design time I don't know the size of the tables. I need to place the 2nd table right after the first, but I dont know the position of the first (I can't calculate it because I dont know how big it is). How do I know where to place the second table?
You can figure out the total height of the table dynamically. After you use the WriteSelectedRows() function, you can call the .TotalHeight() property to find out how tall your table was (in points). Then figure out with some calculations where it ends and where the next one should begin.
That's right the table height and width is dynamically calculated, but you don't have to call WriteSelectedRows() function. You have to set either height or width.
In my case I had to first calculate that if font used can fill the page if not I had to dynamically change the font appropriately. So I find (by mistake) if you set TotalWidth the TotalHeight is automatically set/calculated.
Sanjay