Connecting Tech Pros Worldwide Forums | Help | Site Map

format a column in excel from Access using VB

Newbie
 
Join Date: Jul 2007
Posts: 11
#1: Jul 17 '07
I need to format a column in excel but would like to do it from Access using VB. I have hacked around and found a few ways to get to the workbook but have a problem getting to the sheet i want. But, how do i format a cell in excel from Access using VB? I have most of my vb code in access but i am running into some formatting difficulties on the excel side and want to keep all my code under Access. Thanks.

ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,219
#2: Jul 17 '07

re: format a column in excel from Access using VB


Quote:

Originally Posted by ofilha

I need to format a column in excel but would like to do it from Access using VB. I have hacked around and found a few ways to get to the workbook but have a problem getting to the sheet i want. But, how do i format a cell in excel from Access using VB? I have most of my vb code in access but i am running into some formatting difficulties on the excel side and want to keep all my code under Access. Thanks.

You would use Automation code to create an Instance of Excel, make a specific Worksheet the active Sheet, then apply direct formatting to a Column in the Worksheet by using VBA code from within Access. I'm going to bed now, but if you need further assistance on this Topic, please let us know. Either a Moderator, Expert, another User, or myself will get back to you in due time.
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 347
#3: Jul 17 '07

re: format a column in excel from Access using VB


Quote:

Originally Posted by ofilha

I have hacked around and found a few ways to get to the workbook but have a problem getting to the sheet i want. But, how do i format a cell in excel from Access using VB?.

Assuming you have opened Excel and the workbook using Automation then this formats a column

oExcel.Sheets("SheetName").Columns("A").NumberForm at = "dd/mm/yy"

Where oExcel is the Excel Application object.

Does that help?

This is the base essential, it depend what you are doing, but if you are using this (or any other sheet) to do a significant amout, then you can make the sheet the acative sheet or set the sheet to and object variable or use the With constuct to refer to it.


MTB
Newbie
 
Join Date: Jul 2007
Posts: 11
#4: Jul 17 '07

re: format a column in excel from Access using VB


Thanks to all who offered suggestions. I may not be able to get back to you until this weekend,as it is not my main project. As soon as i get to work on it i will let you folks know my results.
Reply