473,748 Members | 6,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Format Excel document from Access

94 New Member
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 9012
ADezii
8,834 Recognized Expert Expert
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 Recognized Expert Expert
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 New Member
Thanks!! just what i was after, and no need for hyperlink to open the excel document.

One other question though.....(sor ry!)
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 Recognized Expert Expert
Thanks!! just what i was after, and no need for hyperlink to open the excel document.

One other question though.....(sor ry!)
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 "MicrosoftExcel Biff8(*.xls)" for acFormatXLS
Feb 13 '08 #5
Lewe22
94 New Member
Unfortunately that has made no difference...
Feb 14 '08 #6
ADezii
8,834 Recognized Expert Expert
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
5207
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 db3 table. I've been suggested that once I export it to an Excel file, the user has to open the document and to save it as dbase III (.dbf) file I expect I should be able to do this operation by code, using VBA. Any suggestions appreciated
4
1768
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 using code to create an Excel 2000 or 2002 file? Marcus ******
4
8843
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 works and sometimes doesnt. When it doesnt, it gives me a 1004 "Method of Columns" of object variable failed error. My only guess is a timing issue. For instance, sometimes Excel is
17
6346
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
3701
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 opened. Inside the Excel template, I have assigned a draft watermark to the Print icon. When the Print icon is clicked, the draft watermark and print dialog box is shown. After the user print/edit data in the Excel template, s/he has to click
1
1651
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 cycle through and create one report per record (I need 20 individual PDFs for e-mailing). When I use the 'DoCmd.OpenReport "rptAnnualPkg", acViewNormal', Access prints it before all the Word and Excel objects load and I have reports with huge...
4
2021
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 well except for a very strange problem. Let's say a column should say 16500.22. When I run it here from the uk, the cell will show 16500.22 When someone in Netherlands runs it, the cells shows 16,500,220,000 It looks like Excel is mixing the...
6
7901
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 Access 2002 with Excel 2002. So M$ suggest using older Biff5 format (from Office 2000) instead of Biff8. But Biff5 has a problem too. Numbers from fields with input mask set are pasted in Excel as text, if you copy the record (not one field). On the...
1
3741
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 accomplished with the following line: DoCmd.TransferSpreadsheet acExport, , "MyQuery", "ExcelFileName", True
0
8987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8239
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.