I have succesfully exported an Access report to Excel and then opened it, now i want to format it: - Private Sub Command2_Click()
-
-
Dim Date1
-
Dim stReportAddress As String
-
-
Date1 = Format(Date, "dd-mm-yyyy")
-
stReportAddress = "c:\my documents\siobhan\Employer Funding Report - By Employer (" & Date1 & ").xls"
-
-
'Export Report
-
DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", acFormatXLS, stReportAddress
-
-
'Open Report
-
Application.FollowHyperlink stReportAddress
-
-
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: - Cells.Select
-
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?????
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: - Private Sub Command2_Click()
-
-
Dim Date1
-
Dim stReportAddress As String
-
-
Date1 = Format(Date, "dd-mm-yyyy")
-
stReportAddress = "c:\my documents\siobhan\Employer Funding Report - By Employer (" & Date1 & ").xls"
-
-
'Export Report
-
DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", acFormatXLS, stReportAddress
-
-
'Open Report
-
Application.FollowHyperlink stReportAddress
-
-
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: - Cells.Select
-
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).
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: - Private Sub Command2_Click()
-
-
Dim Date1
-
Dim stReportAddress As String
-
-
Date1 = Format(Date, "dd-mm-yyyy")
-
stReportAddress = "c:\my documents\siobhan\Employer Funding Report - By Employer (" & Date1 & ").xls"
-
-
'Export Report
-
DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", acFormatXLS, stReportAddress
-
-
'Open Report
-
Application.FollowHyperlink stReportAddress
-
-
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: - Cells.Select
-
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: -
'The following code will open an Excel Spreadsheet via Automation,resize all Columns
-
'in the Worksheet, set the Size and Bold attributes for a specific Cell, then Exit
-
'while saving the changes
-
-
Dim Date1 As Date, strReportAddress As String
-
Dim objActiveWkb As Object, appExcep As Object
-
-
Set appExcel = CreateObject("Excel.Application")
-
appExcel.Visible = False
-
-
appExcel.Application.Workbooks.Open ("C:\Test\TestReport.xls")
-
-
Set objActiveWkb = appExcel.Application.ActiveWorkbook
-
-
With objActiveWkb
-
.Worksheets(1).Cells.Select
-
.Worksheets(1).Cells.EntireColumn.AutoFit
-
.Worksheets(1).Cells(5, 3).Font.Size = 14
-
.Worksheets(1).Cells(5, 3).Font.Bold = True
-
End With
-
-
objActiveWkb.Close savechanges:=True
-
-
appExcel.Application.Quit
-
-
Set objActiveWkb = Nothing: Set appExcel = Nothing
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. - 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?
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. - 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
Unfortunately that has made no difference...
ADezii 8,834
Recognized Expert Expert
Unfortunately that has made no difference...
You got me stumped for now, sorry.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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
******
|
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
|
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
|
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
| |
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...
|
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...
|
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...
|
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
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |