473,382 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Format Excel document from Access

94
I have succesfully exported an Access report to Excel and then opened it, now i want to format it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command2_Click()
  2.  
  3.     Dim Date1
  4.     Dim stReportAddress As String
  5.  
  6.     Date1 = Format(Date, "dd-mm-yyyy")
  7.     stReportAddress = "c:\my documents\siobhan\Employer Funding Report - By Employer (" & Date1 & ").xls"
  8.  
  9.     'Export Report
  10.     DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", acFormatXLS, stReportAddress
  11.  
  12.     'Open Report
  13.     Application.FollowHyperlink stReportAddress
  14.  
  15. End Sub
Not sure how to perform the formatting now it is open...

I basically want to resize all the columns, create a header and place a few cells in bold.

Take resizing the columns, i know the code from the excel document would be:

Expand|Select|Wrap|Line Numbers
  1. Cells.Select
  2. Cells.EntireColumn.AutoFit
I'm just not sure how to prefix it as simply putting that code in doesn't work.

Any ideas out there?????
Feb 13 '08 #1
6 8983
ADezii
8,834 Expert 8TB
I have succesfully exported an Access report to Excel and then opened it, now i want to format it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command2_Click()
  2.  
  3.     Dim Date1
  4.     Dim stReportAddress As String
  5.  
  6.     Date1 = Format(Date, "dd-mm-yyyy")
  7.     stReportAddress = "c:\my documents\siobhan\Employer Funding Report - By Employer (" & Date1 & ").xls"
  8.  
  9.     'Export Report
  10.     DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", acFormatXLS, stReportAddress
  11.  
  12.     'Open Report
  13.     Application.FollowHyperlink stReportAddress
  14.  
  15. End Sub
Not sure how to perform the formatting now it is open...

I basically want to resize all the columns, create a header and place a few cells in bold.

Take resizing the columns, i know the code from the excel document would be:

Expand|Select|Wrap|Line Numbers
  1. Cells.Select
  2. Cells.EntireColumn.AutoFit
I'm just not sure how to prefix it as simply putting that code in doesn't work.

Any ideas out there?????
Just subscribing to this unanswered Thread, will get back to you later on, hopefully with an answer. (LOL).
Feb 13 '08 #2
ADezii
8,834 Expert 8TB
I have succesfully exported an Access report to Excel and then opened it, now i want to format it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command2_Click()
  2.  
  3.     Dim Date1
  4.     Dim stReportAddress As String
  5.  
  6.     Date1 = Format(Date, "dd-mm-yyyy")
  7.     stReportAddress = "c:\my documents\siobhan\Employer Funding Report - By Employer (" & Date1 & ").xls"
  8.  
  9.     'Export Report
  10.     DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", acFormatXLS, stReportAddress
  11.  
  12.     'Open Report
  13.     Application.FollowHyperlink stReportAddress
  14.  
  15. End Sub
Not sure how to perform the formatting now it is open...

I basically want to resize all the columns, create a header and place a few cells in bold.

Take resizing the columns, i know the code from the excel document would be:

Expand|Select|Wrap|Line Numbers
  1. Cells.Select
  2. Cells.EntireColumn.AutoFit
I'm just not sure how to prefix it as simply putting that code in doesn't work.

Any ideas out there?????
The following will be more than enough to get you on the right track:
Expand|Select|Wrap|Line Numbers
  1. 'The following code will open an Excel Spreadsheet via Automation,resize all Columns
  2. 'in the Worksheet, set the Size and Bold attributes for a specific Cell, then Exit
  3. 'while saving the changes
  4.  
  5. Dim Date1 As Date, strReportAddress As String
  6. Dim objActiveWkb As Object, appExcep As Object
  7.  
  8. Set appExcel = CreateObject("Excel.Application")
  9. appExcel.Visible = False
  10.  
  11. appExcel.Application.Workbooks.Open ("C:\Test\TestReport.xls")
  12.  
  13. Set objActiveWkb = appExcel.Application.ActiveWorkbook
  14.  
  15. With objActiveWkb
  16.    .Worksheets(1).Cells.Select
  17.    .Worksheets(1).Cells.EntireColumn.AutoFit
  18.    .Worksheets(1).Cells(5, 3).Font.Size = 14
  19.    .Worksheets(1).Cells(5, 3).Font.Bold = True
  20. End With
  21.  
  22. objActiveWkb.Close savechanges:=True
  23.  
  24. appExcel.Application.Quit
  25.  
  26. Set objActiveWkb = Nothing: Set appExcel = Nothing
Feb 13 '08 #3
Lewe22
94
Thanks!! just what i was after, and no need for hyperlink to open the excel document.

One other question though.....(sorry!)
When performing the save it tells me that the file "is a Microsoft Excel 5.0/95 Workook. Do you want to overwrite it with the latest Excel format?"

I presume this has something to do with when the report is exported..... though i'm not sure where. I am running Office 2003 and don't understand why it would export the file in an older format.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", acFormatSNP, SnpRptAddressByEmpl
I have looked into acFormat but XLS is the only excel format.
The way i see it i can either somehow try to export the file in the latest format, or i can automatically have the code say "Yes" when the pop up appears.

Can you help?
Feb 13 '08 #4
ADezii
8,834 Expert 8TB
Thanks!! just what i was after, and no need for hyperlink to open the excel document.

One other question though.....(sorry!)
When performing the save it tells me that the file "is a Microsoft Excel 5.0/95 Workook. Do you want to overwrite it with the latest Excel format?"

I presume this has something to do with when the report is exported..... though i'm not sure where. I am running Office 2003 and don't understand why it would export the file in an older format.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", acFormatSNP, SnpRptAddressByEmpl
I have looked into acFormat but XLS is the only excel format.
The way i see it i can either somehow try to export the file in the latest format, or i can automatically have the code say "Yes" when the pop up appears.

Can you help?
Try substituting "MicrosoftExcelBiff8(*.xls)" for acFormatXLS
Feb 13 '08 #5
Lewe22
94
Unfortunately that has made no difference...
Feb 14 '08 #6
ADezii
8,834 Expert 8TB
Unfortunately that has made no difference...
You got me stumped for now, sorry.
Feb 14 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Nicolae Fieraru | last post by:
Hi All, I have an access query which retrieves some record. I can export the results of it as an excel document, using the function TransferText. What I actually need is to export the query as a...
4
by: Marcus | last post by:
I am using the following command to open a query in Excel: DoCmd.OutputTo acOutputQuery, "qryTest", acFormatXLS, , True The problem is that the code creates an Excel 97 file. Is there a way...
4
by: BerkshireGuy | last post by:
I have the following Access code that exports to Excel, inserts a title, changes the color of the title, and then changes the format of several columns to currency. The following code sometimes...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
1
by: Bon | last post by:
Hello all I create a form with three buttons in MS Access 2000. They are Open Excel Template, Save Draft and Save Final. When I click the Open Excel Template button, the Excel template will be...
1
by: musicloverlch | last post by:
I have a problem. I have an Access 2003 report that contains a number of Word and Excel objects with fancy formatting and spreadsheets, etc. I have about 20 records that I am having the database...
4
by: toffee | last post by:
Hi all, I created a little button which when clicked will run a query on mysql db and output the results as an excel spreadsheet. I do this by setting the header as application excel. All works...
6
dima69
by: dima69 | last post by:
Biff format is defined as default format for copying data from Access to Excel (under registry key ...\Access\Clipboard Formats). This format has a known problem as numbers are pasted as text using...
1
by: Joe Humburg | last post by:
Hi everyone, Looking for some help or ideas, on the folloiwng problem. Have an Access 2003 application that creates an Excel file containing data from an Access parameter query. This is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.