Vous êtes sur la page 1sur 4

Integrating Excel and Other Office Applications Hc Access th hc ci g???

Macro 92: Running an Access Query from Excel ang lc li v cha bit phi hc lm sao v hc
Phi hiu Microsoft access queries l ci u g ci g?
trc Nn tp trung vo table v display-import data
Sau hon chnh form cao cp
Here's a macro for those of you who often copy V sau cng quan trng hn ht thy l
and paste the results of your Microsoft Access querries, nhiu querries.
queries to Excel.

In this macro, you use DAO (Data Access Object)


to open and run an Access query in the
background and output the results into
Excel.
Macro 93: Running an Access Macro from Excel
Kt hp nhiu queries, nn tht ra cng phi bit
queries l ci u g????
You can run Access macros from Excel, using
automation to fire the macro without opening
Access.
This technique can be useful not only for running
those epic macros that involve a multistep series
of 20 queries,
but can also come in handy for everyday tasks like
outputting a Access data to an Excel file
Macro 94 Opening an Access Report from Excel
Report, report report l ci ging g????
Access reports allow you to build professional
looking reports that have a clean PDF-style look
and feel.
If you run and distribute a great deal of Access
reports, the following macro can help automate
your processes.

Macro 95 Opening an Access Form from Excel


Acess Form l ci ging g????
In some instances, you or your clients may need to
switch focus to an Access form. This example
demonstrates how you can open an Access form
from Excel.
Macro 96 Compacting an Access Database from
Excel

During your integrated processes, you may


routinely increase or decrease the number of
records and tables in your database.
As time goes on, you may notice that your Access
database gets bigger. This is because Access does
not release file space.
All the space needed for the data you move in and
out of your database is held by your Access file,
regardless of whether the data is still there.

In that light, it's critical that you run Compact and


Repair on your Access database regularly. Among
other things, running Compact and Repair
defragments your database, releasing any unused
space and ensuring your database does not grow
to an unmanageable size.

Office automation enables you to Compact and


Repair your databases right from code.
In This Part
Macro 62 Create a Backwards-Compatible PivotTable
Macro 63 Refresh All PivotTables Workbook
Macro 64 Create a PivotTable Inventory Summary
Macro 65 Make All PivotTables Use the Same Pivot Cache
Macro 66 Hide All Subtotals in a PivotTable
Macro 67 Adjust All Pivot Data Field Titles
Macro 68 Set All Data Items to Sum
Macro 69 Apply Number Formatting for All Data Items
Macro 70 Sort All Fields in Alphabetical Order
Macro 71 Apply Custom Sort to Data Items
Macro 72 Apply PivotTable Restrictions
Macro 73 Apply Pivot Field Restrictions
Macro 74 Automatically Delete Pivot Table Drill-Down Sheets
Macro 75 Print Pivot Table for Each Report Filter Item
Macro 76 Create New Workbook for Each Report Filter Item
Macro 77 Transpose Entire Data Range with a PivotTable

Part VI: Working with PivotTables


Macro 63: Refresh All PivotTables Workbook

It's not uncommon to have multiple PivotTables in the same


workbook. Many times, these pivotTables link to data that
changes, requiring a refresh of the PivotTables. If you find that
you need to refresh your PivotTables en masse, you can use
this macro to refresh all PivotTables on demand.
Macro 64: Create a PivotTable Inventory Summary

When your workbook contains multiple PivotTables, it's often


helpful to have an inventory summary (similar to the one
shown here in Figure 6-1) that outlines basic details about the
PivotTables.

With this type of summary, you can quickly see important


information like the location of each PivotTable, the location of
each PivotTable's source data, and the pivot cache index each
PivotTable is using

Macro 65: Make All PivotTables Use the Same Pivot Cache

If you work with PivotTables enough, you will undoubtedly find


the need to analyze the same dataset in multiple ways.
In most cases, this process requires you to create separate
PivotTables from the same data source.
The problem is that each time you create a PivotTable, you are
storing a snapshot of the data source in a pivot cache. Every
pivot cache that is created increases your memory usage and
file size.
The side effect of this behavior is that your spreadsheet bloats
with redundant data.
You can refresh one PivotTable and all others that share the
pivot cache are refreshed also.
When you add a Calculated Field to one PivotTable, your
newly created calculated field shows up in the other
PivotTables' field list.
When you add a Calculated Item to one PivotTable, it shows
up in the others as well.
Any grouping or ungrouping you perform affects all
PivotTables sharing the same cache.

Macro 66: Hide All Subtotals in a PivotTable

When you create a PivotTable, Excel includes subtotals by


default. This inevitably leads to a PivotTable report that
inundates the eyes with all kinds of numbers, making it difficult
to analyze.

Macro 71: Apply Custom Sort to Data Items

On occasion, you may need to apply a custom sort to the data


items in your PivotTable. For instance, if you work for a
company in California, your organization may want the West
region to come before the North and South.
In these types of situations, neither the standard ascending nor
descending sort order will work.

Vous aimerez peut-être aussi