vc6.0呼叫excel xp,word 2k (轉)
#include
#include
#pragma warning (disable:4146 4192 4786 4081)
#define USE_1
#ifdef USE_OFFICEXP
#import "C:Program FilesCommon Files SharedOffice10MSO.DLL"
#import "c:Program FilesCommon FilesMicrosoft SharedVBAVBA6VBE6EXT.olb"
#import "c:Program FilesMicrosoft OfficeOffice10MS.olb" rename("Exit","ExitWindowsEx")
#import "c:Program FilesMicrosoft OfficeOffice10.exe" rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL")
rename("DocumentProperties", "DocumentPropertiesXL") exclude("IFont","IPicture")
#else
#import "c:Program FilesMicrosoft OfficeOfficeMSO9.dll"
#import "C:Program FilesCommon FilesMicrosoft SharedVBAVBA6VBE6EXT.OLB" no_namespace
#import "c:Program FilesMicrosoft OfficeOfficeMSWORD9.OLB" rename("ExitWindows","_ExitWindows")
#import "c:Program FilesMicrosoft OfficeOfficeexcel9.olb" rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL")
rename("DocumentProperties", "DocumentPropertiesXL") exclude("IFont","IPicture")
#endif
int main(int argc, char* argv[])
{
VARIANT varItem;
varItem.vt = VT_I4;
varItem.intVal = 1;
::CoInitialize(NULL);
CLSID clsid;
#if 0
CLSIDFromProgID(L"Word.Application", &clsid);
Word::_ApplicationPtr pApp;
pApp.CreateInstance (clsid,NULL);
pApp ->PutVisible (VARIANT_TRUE);
pApp ->GetDocuments() ->Add();
Word::_DocumentPtr pWordDocument =pApp-> GetActiveDocument();
Word::ionPtr pSelection = pApp ->GetSelection();
pSelection ->TypeText("badguy");
#endif
#if 1
CLSIDFromProgID(L"Excel.Application", &clsid);
Excel::_ApplicationPtr pApp;
pApp .CreateInstance (clsid,NULL);
pApp ->PutVisible (0,VARIANT_TRUE);
Excel::_WorkbookPtr pWorkbook = pApp ->GetWorkbooks () ->Add ();
Excel::_WorksheetPtr pSheet = pWorkbook ->GetWorksheets () ->GetItem (varItem);
Excel::RangePtr pRange = pSheet ->GetUsedRange(0);
int iColCnt = pRange ->GetColumns() ->GetCount();
printf("used columns is %d
",iColCnt);
int iRowCnt = pRange ->GetRows() ->GetCount();
printf("used rows is %d
",iRowCnt);
pRange = pSheet ->GetRange(OLESTR("A1"));
pRange ->Value2 = OLESTR("SOME");
Excel::InteriorPtr pInterior= pRange ->GetInterior ();
varItem.intVal = 0xff0000;
pInterior ->PutColor (varItem);
pSheet ->PrintPreview ();
#endif
::CoUninitialize();
return 0;
}
好久沒回復貼子,今天看到一個excel的問題。於是寫了一下。寫完了再儲存。順便發一下。這可是原創的哈。好想有三顆星星了。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-963035/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- word與excel轉pdf方法Excel
- 如何將Word文件轉成Excel表格?Excel
- WORD及EXCEL行列轉換實現方法收藏(轉)Excel
- 在VC6.0中呼叫瀏覽器訪問WEB頁面 (轉)瀏覽器Web
- VB千里行-操作Word與Excel (轉)Excel
- 在Word中嵌入已有的Excel工作表(轉)Excel
- 利用Delphi 5中呼叫Excel 97 (轉)Excel
- Word轉PPT\Excel的技巧方法,辦公更高效Excel
- Word與Excel組合工作 批次列印信封(轉)Excel
- word放不下excel表格怎麼辦 word放不下excel表格的方法Excel
- Word與Excel PPT文件"減肥"之雕蟲小技(轉)Excel
- 使用NPOI讀寫Excel、WordExcel
- 匯出Excel或word文件Excel
- 模板匯出word和 EXcelExcel
- VC6.0編譯問題 (轉)編譯
- 實用辦公小技巧:Word、Excel、PPT任意轉換教程Excel
- excel表格怎麼轉換成word文件 表格資料轉換到文件Excel
- POI處理Word、Excel、PowerPointExcel
- 在.NET環境下將報表匯出EXCEL和WORD (轉)Excel
- vc6.0(完整綠色版)(支援XP、Win7、Win8、Win10)Win7Win10
- c#中呼叫ExcelC#Excel
- 在VC中呼叫WORD(顯示,修改,存檔,執行宏) (轉)
- 在VC中呼叫WORD(顯示,修改,存檔,執行宏)之三。呼叫word的各種對話方塊翻頁等。 (轉)
- 如何將excel表格匯入word並保持格式不變 如何把excel的表格弄到word文件Excel
- 親密接觸VC6.0編譯器 (轉)編譯
- Excel2000/XP和PowerPoint2000/XP下內部COM外掛的實現 (轉)Excel
- excel表格匯入word方法彙總Excel
- 在Excel表格中插入Word文件方法Excel
- asp.net 呼叫 excel 元件ASP.NETExcel元件
- pdf轉word格式PDF to word for MacMac
- Word2000/XP中內部COM外掛的程式設計實現 (轉)程式設計
- excel如何複製到word不變形Excel
- JSP生成WORD文件,EXCEL文件,PDF文件JSExcel
- 在VC中呼叫WORD(顯示,修改,存檔,執行宏)之二去掉word的常用,格式工具欄 (轉)
- 用好Word模板 提高Word操作效率(轉)
- NPOI匯出和匯入Excel,Word和PDFExcel
- 技巧:如何將Word試卷快速匯入Excel?Excel
- php生成匯出Word、Excel、PowerPoint外掛PHPExcel