将查询导出到Excel - 特定工作表,特定范围 [英] Export queries to Excel - specific sheet, specific range

查看:95
本文介绍了将查询导出到Excel - 特定工作表,特定范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我认为这是一个简单的问题,但显然不是。我需要将大约30个查询的内容导出到现有Excel工作簿的特定工作表和单元格区域中。


以下是我在一个示例中需要的所有详细信息转账:


查询=查询A

Excel工作簿=" C:\Documents and Settings \ All Users \ Workbook1.xlsx" ;

Sheet =" BB DATA"

范围= B2:J32

HasFieldNames = True


有很多关于从Access导出到Excel的线程,但我整个下午都搜索过,找不到有效的答案。对不起,如果我是这样的菜鸟,但我不能想出这个。


非常感谢任何帮助

解决方案

嗨CarrieR,

DoCmd.TransferSpreadsheet 函数?

展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号


是的,遗憾的是,TransferSpreadsheet命令的问题在于它不会导出到特定的工作表。这是一个非常重要的需求,因为电子表格是用于大量报告的(复杂)模板...


抱歉,我可能误解了这个问题。由于您希望将生成的记录放入现有的工作簿(excel文件),这里有一个关于我从工作中完成的示例代码。

展开 | 选择 | Wrap | 行号

Hi,

I thought this was a simple issue, but apparently it''s not. I need to export the contents of about 30 queries, each into a specific sheet, and cell range, of an existing Excel workbook.

Here are all of the details I need in one sample transfer:

Query = "Query A"
Excel workbook = "C:\Documents and Settings\All Users\Workbook1.xlsx"
Sheet = "BB DATA"
Range = B2:J32
HasFieldNames = True

There are a lot of threads about exporting to Excel from Access, but I have searched all afternoon and can''t find an answer that works. Sorry if I''m being a noob on this, but I just can''t figure this one out.

Thanks so much for any help

解决方案

Hi CarrieR,

Had you tried using the DoCmd.TransferSpreadsheet function?

Expand|Select|Wrap|Line Numbers


Yes, the problem with the TransferSpreadsheet command, unfortunately, is that it won''t export to a specific sheet. This is a pretty vital need, since the spreadsheet is a (complex) template for a lot of reporting...


Sorry I maybe mis-understood the question. As you want to put the generated records into existing workbooks (excel files), here''s a sample code on what I''ve done from my work.

Expand|Select|Wrap|Line Numbers


这篇关于将查询导出到Excel - 特定工作表,特定范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆