By Bitoubi


2015-04-28 07:37:04 8 Comments

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.

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...

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

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

1 comments

@Jeff Parker 2015-12-16 04:21:00

I just had success using obj.Object.SaveCopyAs instead of obj.Object.SaveAs.

Related Questions

Sponsored Content

13 Answered Questions

[SOLVED] How to avoid using Select in Excel VBA

  • 2012-05-23 05:57:58
  • BiGXERO
  • 250938 View
  • 501 Score
  • 13 Answer
  • Tags:   excel vba

42 Answered Questions

[SOLVED] How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office?

  • 2008-09-29 22:30:28
  • mistrmark
  • 1028507 View
  • 1778 Score
  • 42 Answer
  • Tags:   c# .net excel file-io

2 Answered Questions

[SOLVED] Save a specific sheet as individual xls file with vba

  • 2019-05-13 06:47:45
  • Bildircin13
  • 21 View
  • 1 Score
  • 2 Answer
  • Tags:   excel vba xls

1 Answered Questions

Save File as CSV UTF8 gives error 1004

2 Answered Questions

[SOLVED] Saving embedded OLE Object (Excel workbook) to file in Excel 2010

1 Answered Questions

[SOLVED] When i click NO or CANCEL in MsgBox, i get run time 1004 error in Excel VBA whie saving

  • 2018-10-19 08:44:22
  • Balachandiran
  • 179 View
  • -1 Score
  • 1 Answer
  • Tags:   vba

3 Answered Questions

2 Answered Questions

[SOLVED] Excel VBA .SaveAs breaking in loop

  • 2017-05-10 17:55:13
  • IntegrityAnthony
  • 644 View
  • 0 Score
  • 2 Answer
  • Tags:   excel vba excel-vba

1 Answered Questions

[SOLVED] Struggling to save as xlsx file in VBA

  • 2016-06-01 13:47:41
  • yarz-tech
  • 31795 View
  • 4 Score
  • 1 Answer
  • Tags:   vba save-as

1 Answered Questions

How to save excel file faster with VBA

Sponsored Content