Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-13-2013, 01:16 AM
molesy molesy is offline VBA code to fix column widths Windows 7 64bit VBA code to fix column widths Office 2010 64bit
Novice
VBA code to fix column widths
 
Join Date: Sep 2013
Posts: 8
molesy is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 09-13-2013, 03:18 AM
OTPM OTPM is offline VBA code to fix column widths Windows 7 32bit VBA code to fix column widths Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

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
Reply With Quote
  #3  
Old 09-13-2013, 03:22 AM
molesy molesy is offline VBA code to fix column widths Windows 7 64bit VBA code to fix column widths Office 2010 64bit
Novice
VBA code to fix column widths
 
Join Date: Sep 2013
Posts: 8
molesy is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 09-16-2013, 12:51 PM
BobBridges's Avatar
BobBridges BobBridges is offline VBA code to fix column widths Windows 7 64bit VBA code to fix column widths Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes


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
VBA code to fix column widths Alternate Table Column Widths on even and odd pages robrastelli Word 4 08-08-2012 07:33 PM
VBA code to fix column widths 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

Other Forums: Access Forums

All times are GMT -7. The time now is 02:06 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft