另存为另存为Excel文件的Excel文件 [英] Save as an Excel file embedded in another Excel file

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

问题描述

我想用VBA管理嵌入到另一个Excel文件中的Excel文件。我可以使用.docx文档找到很多结果,但是我坚持使用.xlsx文件。

I want to manage with VBA an Excel file embedded in another Excel file. I can find many results with .docx documents, but I stuck with a .xlsx one.

我最后一次使用OLE对象,但是在SaveAs (错误1004)。
这是奇怪的部分:当我开始调试,或者如果我使用F8一步一步运行程序,它运行,但没有保存文件...

My last try is using OLE objects, but stuck at the line "SaveAs" (Error 1004). Here is the weird part: when I start debugging, or if I run the program step by step using F8, it did run, but no file were saved...

我为这个例子调用了我的OLEObjectTEST:

I called my OLEObject "TEST" for this example:

Sub testOLE()
mPath = ActiveWorkbook.Path

For Each obj In Worksheets(1).OLEObjects
 If obj.Name = "TEST" Then
 obj.Verb
 obj.Object.Activate
 obj.Object.SaveAs mPath & "TEST_success.xlsx"
 obj.Object.Close
End If
 i = i + 1
Next
End Sub

我不明白如何将OLEObjects保存为.xlsx,你能帮我一些吗?

I don't understand how to save OLEObjects as .xlsx, could you help me a bit?

推荐答案

我刚刚成功使用 obj.Object.SaveCopyAs 而不是 obj.Object.SaveAs

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

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