#1
|
|||
|
|||
VBA code to fix column widths
Hi
I have created a document in excel 2010 and i have embeded it into word, the problem is trying to keep the column widths when it embeds if there is more text in one of the cells in either column it reduces the other column width, any suggestions would be appreciated. |
#2
|
|||
|
|||
Hi Molesy
If you double click the embedded excel sheet in MS Word it will open as if you were in Excel itself. From there you can set a fixed column width for each column and set the cell wrapping to on. This should resolve your issue. Tony |
#3
|
|||
|
|||
Hi Tony
thanks, If i wanted to add a button on my userform in excel to automate embedding the document in word could this be done with keeping the column widths thanks |
#4
|
||||
|
||||
I dunno about preserving the column widths, molesy. Tony says you can adjust them manually after it's been embedded, and if that's the case you oughta be able to do it with VBA too. But whether there's any way to embed the workbook in Word without the column widths changing, I couldn't say; I've never experimented with this. Maybe if you set the column widths to some value in Excel and then embed the document, it'll work.
As for your question about the button, sure, you can create a button in Excel that'll embed the workbook in Word. But it's a process that happens in the Word object, so your VBA code in Excel will have to open up the Word object and refer to methods and properties in that object to get it done. That means you have to learn how to do the same task in VBA/Word. The Word object model is different from Excel's (naturally), so it may take some getting used to. I know a little about the Word object, but not very much. If I had to do this, I'd create a VBA program in Word, learn to embed an Excel workbook there, then just figure out how to do the same thing in an Excel macro by invoking the Word application object and going on from there. And of course once you've figured out how to do that, maybe you can have the same program finish up by setting the column width explicitly after the embedding is done, if that's still necessary. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to transpose the datas of part code and supplier into row and column | PRADEEPB270 | Excel | 3 | 10-26-2012 07:22 PM |
VBA code for count w and write into another column in excel | tomlam | Excel Programming | 2 | 10-09-2012 03:56 AM |
Alternate Table Column Widths on even and odd pages | robrastelli | Word | 4 | 08-08-2012 07:33 PM |
Altering Column Widths on Two Col Page | abrogard | Word | 2 | 12-30-2010 06:03 AM |
Seperate Column widths in one worksheet | miller.3276 | Excel | 2 | 01-27-2010 02:12 PM |