Problems with Setting Properties for an Excel Object in Access

B

BFarrell

I am creating Excel reports out of access, and then reformatting the Excel
File when in Access. This works great and I have had much success.

However, I am trying to set the ShrinkToFit property on 2 columns and it is
not setting this property to true.

The following code correctly sets the WrapText property, but does not set
the ShrinkToFit property.

Set xlObject = CreateObject("excel.application")
Set xlbook = xlObject.Workbooks.Open(path_filename)
xlObject.worksheets(Sheet_Name).Activate
With xlObject
.range("C:C").select
.Selection.wraptext = True
.Selection.ColumnWidth = 22
.range("D:D").select
.Selection.ShrinkToFit = True
.Selection.ColumnWidth = 25
End With

Any help would be appreciated!
Thanks!
 
V

vic

I'm assuming that if you set the ShrinkToFit to true, as you do, and
then set the ColumnWidth to a specific size (25) which you also do,
then the ShrinkToFit is re-set to False. You did tell the program to
make the column 25, which should negate the ShrinkToFit.
 
B

BFarrell

Removing the setting of the columnwidth has no affect. The shrinktofit
property is still not updating to True.
 
L

Larry Daugherty

Automation is wonderful but it's easy to lose focus. You're asking
for help with an Excel issue in an Access newsgroup. :)

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top