Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format exported data to excel template 1

Status
Not open for further replies.

DajTwo

Technical User
Jul 17, 2008
157
US
Hi,

How can I have the format of these exported fields to excel to have a phone format (000) 000-0000. The data is stored in the database as 0000000000.

I have changed the format of the cells in the excel template with the result that when the user enters the data directly, the formatting takes effect however not when the data is exported from Access.

Any idea how to include a format in the following lines?

objXLBook.ActiveSheet.Range("J10") = rs.Fields("cust_fax")
objXLBook.ActiveSheet.Range("J9") = rs.Fields("cust_contact_phone")

Thanks

If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
Thanks,

The cell in the excel spreadsheet is formatted correctly and as the template is protected, the error I get is 1004 Unable to set the NumberFormat property of the RangeClass.

I believe I need to format the data going IN excel. Not sure how I would do that..

If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
Got it..

Thanks for the idea of the format command.. Didnt know..


This works..


objXLBook.ActiveSheet.Range("J9") = Format(rs.Fields("cust_contact_phone"), "(###) ###-####")

If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top