通过访问vba编辑/创建excel文件 [英] Editing/creating excel file through access vba
问题描述
我想从访问中自动将数据发送到现有的Excel文件。创建excel对象后,如何从access vba中引用和编辑excel文件中的数据?网上有很多例子说如何创建对象,但我不确定
如何引用已经存在的文件。这可能吗?
I want to send data to an existing excel file automatically from access. After I create an excel object, how do I reference and edit data in the excel file from the access vba? Many examples online say how to create the objects, but I'm not sure how to reference an already existing file. Is this possible?
在下面的示例中,我尝试至少创建一个新 excel文件,并通过访问vba输入数据, 但这也不起作用。
In my example below, I tried to at least create a new excel file and enter data through access vba, but that doesn't work either.
注意:我对对象没有最强的理解。抱歉,如果我的问题根本没有意义。
note: I don't have the strongest understanding of objects. Sorry if my question does not fundamentally make sense.
Sub excelcreation()
Sub excelcreation()
推荐答案
我目前没有方便的示例,但我通常使用Open方法来操作现有的工作簿。类似于:
I don't have an example handy at the moment, but I usually use the Open method to manipulate an existing workbook. Something like:
设置xlWB = objexcel.Workbooks.Open(" c:\ foldername \ filename.xlsx")
Set xlWB = objexcel.Workbooks.Open("c:\foldername\filename.xlsx")
你可以然后用xlWB做你需要的任何事情。
You can then do whatever you need with xlWB.
希望它有帮助......
Hope it helps...
这篇关于通过访问vba编辑/创建excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!