By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,574 Members | 2,960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,574 IT Pros & Developers. It's quick & easy.

Regarding Word 2003

P: 49
hi i'm using MS Word2003 for my VB application which is a report. The word documents contains tables and the cells inside the table contain some fields. My application replaces the field values with Values from database.
The problem i was getting is if the text length that is replaced is more than the cell length it was not displaying at all. So i used the following code to 'autofit' the table. But it fits the text inside the cell and the cell length increases and crosses the page length. I want that it should AUOTOFIT and simultaneously WRAP the text into new line so that the the table length remain fixed. Plz if anybody having any idea share with me. I need the help urgently.

Expand|Select|Wrap|Line Numbers
  1. If (wrdFinApp.ActiveDocument.Tables.Count >= 1) Then
  2.           For liX = 1 To wrdFinApp.ActiveDocument.Tables.Count
  3.                                          With wrdFinApp.ActiveDocument.Tables(liX)
  4.                                             .AllowAutoFit = True
  5.                                             .ApplyStyleFirstColumn = True
  6.                                             .ApplyStyleHeadingRows = True
  7.                                             .ApplyStyleLastColumn = True
  8.                                             .ApplyStyleLastRow = True
  9.                                          End With
  10.          Next liX
  11. End If
Feb 23 '07 #1
Share this Question
Share on Google+
9 Replies


100+
P: 1,646
This might help you out
Expand|Select|Wrap|Line Numbers
  1. mydoc.Tables(1).AutoFitBehavior wdAutoFitContent
Feb 23 '07 #2

P: 49
no this is also not working. Is there is any other way to do this. let me know
Feb 27 '07 #3

100+
P: 1,646
no this is also not working. Is there is any other way to do this. let me know
What is happening when you use this code?
Feb 27 '07 #4

P: 49
hi i'm using MS Word2003 for my VB application which is a report. The word documents contains tables and the cells inside the table contain some fields. My application replaces the field values with Values from database.

The problem i was getting is if the text length that is replaced is more than the cell length, the text doesn't display rather "Display Text Cannot Span More Than One Line" is displayed.

I've two ideas for that.
1> if the text length that is to be replaced is more than the cell length, then it should make wordwrap i.e it should come into the next line without altering the original size of the table and column positions. OR
2> The cell to be AutoFit and each column value must come under the corresponding column name and the table is adjusted accordingly. But the original format of the table must retained.

To do this i used the following code , the cells values are now visible but they are not in proper position. That means one column value comes under another column name. So the total table format gets distorted.

Plz any one having any knowlegde regarding this plz help me. Below is my code. Also mention one thing when to set the property of the table, after replacing the field value or before.

Expand|Select|Wrap|Line Numbers
  1. If (wrdFinApp.ActiveDocument.Tables.Count >= 1) Then
  2.        For liX = 1 To wrdFinApp.ActiveDocument.Tables.Count
  3.                With wrdFinApp.ActiveDocument.Tables(liX)
  4.                         .AllowAutoFit = True
  5.                         .Range.Cells(liY).WordWrap = True
  6.                         .ApplyStyleFirstColumn = True
  7.                         .ApplyStyleHeadingRows = False
  8.                         .ApplyStyleLastColumn = False
  9.                         .ApplyStyleLastRow = False
  10.  
  11.                  End With
  12.          Next liX
  13.  End If

Also i tried the wordwrap property of the cells but its not working. Thanking You
Feb 27 '07 #5

P: 49
If anybody having any solutions for my question , then plz share it with me. Thanking You
Mar 1 '07 #6

100+
P: 1,646
If anybody having any solutions for my question , then plz share it with me. Thanking You
I meant what is happening when you use the code snippet that I posted?
Mar 1 '07 #7

P: 49
The actual table size gets distorted.that means all the column gets resizes as a result of which one row becomes smaller while other is greater length than the former. but all the data gets displayed.
Mar 2 '07 #8

100+
P: 1,646
The actual table size gets distorted.that means all the column gets resizes as a result of which one row becomes smaller while other is greater length than the former. but all the data gets displayed.
So all the data gets displayed. Great. What is it that does not work then?
Mar 2 '07 #9

P: 49
The table size gets changed. Since the size of the cell changes(for which the text length is greater than the cell length), the row length incerases. But i want that all the row length should be same and each column value should be under respective column name irrespective of the change and the original table length should retain.
Mar 2 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.