I need to save the txt file, which is embedded as an object in the Excel workbook.
I had a look at Saving embedded OLE Object (Excel workbook) to file in Excel 2010.
In the workbook, I have an embedded text file and pdf files (for test purposes, but ultimately I need to use txt file). When I point the OLEObject to xlsm and update the fName accordingly, the below command works correctly.
But when I point the OLEObject to txt file and change the extension in fName to txt, it fails with
Run-time error 1004.
What is the command for txt files? I tried SaveAs2 as per the other threads.
Dim uName As String
Dim fName As String
Dim oEmbFile As Object
uName = Left(Environ("AppData"), Len(Environ("AppData")) - 16)
fName = uName & "\Desktop\OTPReport_Vin" & ".xlsm"
Set oEmbFile = wbkCurrent.Worksheets("Compare the changes").OLEObjects("Object 1")
oEmbFile.Object.SaveAs fName