output to Excel

M

Michael Buscio

Quick question. Is there a way to define the font you want to use when
outputting a query to Excel, either thru code or macro?
 
B

Bob Barrows

Michael said:
Quick question. Is there a way to define the font you want to use when
outputting a query to Excel, either thru code or macro?

Maybe modifying the default font in Excel will do it ...
 
P

pat67

Maybe modifying the default font in Excel will do it ...

I tried that. It doesn't work. I have the default as Tahoma, but
whenever i run either code or a macro to output a query, it comes in
as MS Sans Serif and I don't know why.
 
B

Bob Barrows

pat67 said:
I tried that. It doesn't work. I have the default as Tahoma, but
whenever i run either code or a macro to output a query, it comes in
as MS Sans Serif and I don't know why.

I know of no way to control this during the export process. I suspect
you will have to use VBA to automate Excel (see online help - this is
out of scope of the "queries" group. Googling "VBA automate Excel"
should also get you some examples), open the exported .xls file,
highlight the worksheet and change the font
 
P

pat67

I know of no way to control this during the export process. I suspect
you will have to use VBA to automate Excel (see online help - this is
out of scope of the "queries" group. Googling "VBA automate Excel"
should also get you some examples), open the exported .xls file,
highlight the worksheet and change the font

Thanks I will try that
 
T

Tony Toews

Quick question. Is there a way to define the font you want to use when
outputting a query to Excel, either thru code or macro?

Yes, I use VBA for that kind of stuff. Although I haven't done fonts
specifically.

Modules: Transferring Records to Excel with Automation
http://www.mvps.org/access/modules/mdl0035.htm

To start with I'd use Excel as a reference which helps in using
Intellisense in VBA. Then once it's all working I switch to late
binding.

Late binding means you can safely remove the reference and only have
an error when the app executes lines of code in question. Rather than
erroring out while starting up the app and not allowing the users in
the app at all. Or when hitting a mid, left or trim function call.

This also is very useful when you don't know version of the external
application will reside on the target system. Or if your organization
is in the middle of moving from one version to another.

For more information including additional text and some detailed links
see the "Late Binding in Microsoft Access" page at
http://www.granite.ab.ca/access/latebinding.htm

Finally I like to do the Auto Formatting myself.

Set objSht = objWkb.Worksheets(conSheetName)
With objSht
.....
' Autofit the cells
.range(.Cells(CurrentHeadingRow + 1, 1), .Cells(rsRecordCount
+ CurrentHeadingRow + 1, _
iCountOfCols)).Columns.AutoFit

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top