I'm trying to export HTML file with pictures to Excel using C++ OLE Automation.
Sample of code:
#import "\\alpha\sdk\mso\office12\mso.dll" rename( "RGB", "MSORGB" ) rename("DocumentProperties", "MSODocumentProperties") rename("SearchPath", "MSOSearchPath")
using namespace Office;
#import "\\alpha\sdk\mso\office12\VBE6EXT.OLB" rename( "RGB", "MSORGB" ) rename("EOF", "EndOfFile")
using namespace VBIDE;
#import "\\alpha\sdk\mso\office12\excel.exe" rename( "DialogBox", "ExcelDialogBox" ) rename( "RGB", "ExcelRGB" ) rename( "CopyFile", "ExcelCopyFile" ) rename( "ReplaceText", "ExcelReplaceText" ) no_auto_exclude
#import "\\alpha\sdk\mso\office12\msword.olb" rename( "DialogBox", "WordDialogBox" ) rename( "RGB", "WordRGB" ) rename( "CopyFile", "WordCopyFile" ) rename( "ReplaceText", "WordReplaceText" ) rename( "ExitWindows", "WordExitWindows" ) rename( "FindText", "WordFindText" ) no_auto_exclude
// Create Excle application OLE obj...
Excel::_ApplicationPtr pApplication;
HRESULT hRes = pApplication.CreateInstance(_T("Excel.Application"));
if (hRes==S_OK) {
pApplication->PutDisplayAlerts(MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL), SORT_DEFAULT), VARIANT_FALSE);
pApplication->PutCopyObjectsWithCells(MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL), SORT_DEFAULT), VARIANT_TRUE);
// Open prepeared for export HTML file
Excel::_WorkbookPtr pBook = pApplication->Workbooks->Open( _bstr_t(szHTMLPath), _variant_t((long)Excel::xlUpdateLinksAlways), vtMissing, vtMissing/*_variant_t((long)Excel::xlHtml)*/ );
if (pBook!=NULL) {
//Save opened HTML file as XSL file
hRes = pBook->SaveAs(_bstr_t(szXLSPath), _variant_t((long)Excel::xlWorkbookNormal), vtMissing, vtMissing, vtMissing, vtMissing, Excel::xlNoChange, _variant_t((long)Excel::xlLocalSessionChanges), _variant_t(false));
if (hRes==S_OK) {
// All is ok
}
pBook->Close();
}
pApplication->Quit();
}
Unfortunately, the img pictures from of the html code is not converted into an embedded image, but in the external linked images. How do I convert images to store them internally in the XLS file as an embedded object?