从Access 2010 VBA打开Excel 2010文件 [英] Open Excel 2010 file from Access 2010 VBA

查看:163
本文介绍了从Access 2010 VBA打开Excel 2010文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的计算机上同时具有Excel 2003和Excel 2010.我在Access 2010中使用VBA在Excel 2010中打开2010 .xlsx文件,但我注意到它们似乎在Excell 2003中正在打开",因为该小转换数据"对话框会弹出一会儿.

I have both Excel 2003 and Excel 2010 on my machine. I'm using VBA in Access 2010 to open 2010 .xlsx files in Excel, but I notice they seem to be "opening" in Excell 2003 because that little "Converting data" dialog box pops up for a moment.

是否有一种简单的方法可以确保在打开文件之前先打开Excel 2010?

Is there an easy way to be sure that Excel 2010 "opens" before the files open?

谢谢

Ed

推荐答案

我的计算机上没有两个版本的Excel,因此无法测试,但我认为以下内容将打开默认的Excel版本,我认为您可以将作为2010,然后打开文件. debug.print会告诉您打开了哪个Excel版本.

I don't have two versions of Excel on my computer so cannot test but I would think that the following would open the default Excel version, which I assume you would have as 2010, and then open the file. The debug.print will tell you which Excel version is opened.

或者,您需要2003吗?为什么不卸载?

Alternatively, do you need 2003? Why not uninstall?

Dim xlApp As Excel.Application
Set xlApp = CreateObject("Excel.Application")

xlApp.visible = TRUE

xlApp.Workbooks.Open "C:\FolderName\FileName.xlsx", True, False
Debug.Print xlApp.Version
set xlApp = NOTHING

对不起,我还应该注意,这会在您的计算机上打开一个新的Excel实例,在您要执行的操作的最后

Sorry, I should also note that this opens a new instance of Excel on your machine, at the end of what you want to do you should use

xlApp.Quit

要关闭该实例,以使您的计算机上没有多个实例在运行.

To close the instance so you don't have multiple instances running on your machine.

此外,如果您出于任何原因需要查看电子表格

Also, if you need to see the spreadsheet for any reason

xlApp.Visible = True

会为你做

这篇关于从Access 2010 VBA打开Excel 2010文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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