A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Can not set column width by code



 
 
Thread Tools Display Modes
  #1  
Old December 17th 05, 02:48 AM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default Can not set column width by code

I try to generate a MS Word document from database by Word automation code,
such as “Word.Document.Add”. Everything is OK. I can render data from
database and create new doc file with designed contents.

But one thing is wrong. I can not set column width in a table. When
executing a line of code, I always get error message, said “An unhandled
exception of type 'System.Runtime.InteropServices.COMException' occurred in
MyAppName.exe” and “Additional information: Cannot access individual columns
in this collection because the table has mixed cell widths.”.

The line code is:
objWordTable.Columns(1).Width = 150

It’s not about width. I move this code around, and the error message
sometimes is changed to “object has been deleted”.

I use VB.NET. I think, it’s nothing to do the code. I run some code in
another computer, the code just fine. So, it may be something about my MS
Word settings (options settings in my machine), but I don’t know how to
correct it. It’s real a noise and I can not continue to do further
programming.

Anyone has idea? If this is not right newsgroup to post, please point me a
new newsgroup.
Thanks ahead.

Shaw

Ads
  #2  
Old December 17th 05, 08:08 AM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default Can not set column width by code

Does objWordTable refer to a specific table in the document? You better
show us more of the code.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Shaw" wrote in message
...
I try to generate a MS Word document from database by Word automation code,
such as "Word.Document.Add". Everything is OK. I can render data from
database and create new doc file with designed contents.

But one thing is wrong. I can not set column width in a table. When
executing a line of code, I always get error message, said "An unhandled
exception of type 'System.Runtime.InteropServices.COMException' occurred
in
MyAppName.exe" and "Additional information: Cannot access individual
columns
in this collection because the table has mixed cell widths.".

The line code is:
objWordTable.Columns(1).Width = 150

It's not about width. I move this code around, and the error message
sometimes is changed to "object has been deleted".

I use VB.NET. I think, it's nothing to do the code. I run some code in
another computer, the code just fine. So, it may be something about my MS
Word settings (options settings in my machine), but I don't know how to
correct it. It's real a noise and I can not continue to do further
programming.

Anyone has idea? If this is not right newsgroup to post, please point me a
new newsgroup.
Thanks ahead.

Shaw



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reducing column width in a word table Karthik N Tables 5 December 19th 05 07:45 AM
Formatting and column width problems BethB Tables 0 October 27th 05 10:15 PM
Changing Column width on Multiple tables.. WordHack Tables 1 May 7th 05 03:24 PM
table column width problems Dena Tables 2 March 8th 05 04:51 AM
Can tables be permanently set to Fixed Column Width? Klaus Linke Tables 0 October 26th 04 04:27 PM


All times are GMT +1. The time now is 02:36 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 2004-2014 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.