Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
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 Its 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, its 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 dont know how to correct it. Its 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 |
#2
Posted to microsoft.public.word.tables
|
|||
|
|||
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 |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Reducing column width in a word table | Tables | |||
Formatting and column width problems | Tables | |||
Changing Column width on Multiple tables.. | Tables | |||
table column width problems | Tables | |||
Can tables be permanently set to Fixed Column Width? | Tables |