Excel Crashes while saving embedded file thru VBA

megahurtz

New Member
Joined
Aug 16, 2011
Messages
17
Hi All,

I have a code that opens an embedded excel thru VBA, saves it on a user-specified location, closes the embedded file. Then the saved file will be opened and edited,
The problem that i'm facing is dat when i try to save the embedded sheet, excel crashes with no specified error. It simply crashes. I've no idea what to do. Please help....


My code is as shown below:

Code:
Set XlWbk = ThisWorkbook

Set oEmbFile = XlWbk.Sheets("Release Note Template").OLEObjects("Release Note Template")
oEmbFile.Verb Verb:=xlPrimary
Set XlRN = oEmbFile.Object

re_path2:
saveaspath = Application.GetSaveAsFilename(InitialFileName:=home, Title:="Save the Release Note as...", _
                    FileFilter:="Excel 2007 Files (*.xlsx), *.xlsx, Excel 97-2003 Files (*.xls), *.xls")
'Application.StatusBar = "Saving the Release Note..."
a = MsgBox("Save the Release Note on path " & saveaspath & "?", vbQuestion + vbYesNo)
If a = vbNo Then GoTo re_path2
'XlRN.SaveCopyAs saveaspath
XlRN.Activate
XlRN.SaveAs filename:=saveaspath, ReadOnlyRecommended:=False, CreateBackup:=False ', FileFormat:=xlNormal
XlRN.Close
Set oEmbFile = Nothing
Set XlRN = Nothing

Set XlRN = oExcel.Workbooks.Open(saveaspath)

XlWbk.Activate
wsRNT.Activate
The Excel crashes at point
Code:
XlRN.SaveCopyAs saveaspath
or
Code:
XlRN.SaveAs filename:=saveaspath...
Please guide. Thanks in advance... :)
 
Another problem that i'm facing now. I open the embedded workbook, then i ACTIVATE it, then save it. The code looks like

Code:
XlRN.Activate                               'XlRn refers to the embedded book
ActiveWorkbook.savesas "<Destination_Folder>"

The problem here i face is that Activeworkbook does not refer to the embedded book. It refers to my Original Book, where i had embedded the other book. It's driving me nuts!!:confused:

Please help how can i direct the property ActiveWorkbook to the embedded book.

Thanks a lot in advance!! :)
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,215,973
Messages
6,128,042
Members
449,414
Latest member
sameri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top