DoCmd.TransferSpreadsheet无法识别工作表名称 [英] DoCmd.TransferSpreadsheet is not recognizing worksheet name

查看:166
本文介绍了DoCmd.TransferSpreadsheet无法识别工作表名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用DoCmd.TransferSpreadsheet从Excel工作簿中导入工作表.工作表的名称为XYZ Priority.

I'm trying to import a sheet from an Excel workbook using DoCmd.TransferSpreadsheet. The sheet's name is XYZ Priority.

我正在按如下方式调用该方法:

I'm calling the method as follows:

DoCmd.TransferSpreadsheet FileName:=filePath, tablename:="XYZ", _
                          hasfieldnames:=True, range:="[XYZ Priority]!"

我收到此错误消息:

'[XYZ Priority]$' is not a valid name. Make sure that it does not 
include invalid characters or punctuation and that it is not too long.

似乎是造成问题的原因所在.我尝试了几种不同的方法来识别范围(带有或不带有感叹号),但均失败了:

It appears that the space is what's causing the problem. I've tried several different ways to identify the range, with and without exclamation points, and all have failed:

"XYZ Priority"
"XYZ_Priority"
"'XYZ Priority'"

我如何正确地将工作表传递给TransferSpreadsheet?

How can I correctly pass the sheet to TransferSpreadsheet?

推荐答案

仅使用工作表名称,后跟$符号.

Use just the sheet name followed by the $ sign.

DoCmd.TransferSpreadsheet FileName:=filePath, TableName:="XYZ", _
    HasFieldNames:=True, Range:="XYZ Priority$"

这篇关于DoCmd.TransferSpreadsheet无法识别工作表名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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