Delhpi中如何调用Word、Excel呢? 请高手赐教:在程序中如何用代码实现调用Word、Excelk呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在6当中servers_worddoucment,excelapplication.! 调用excel从server中选择ExcelApplication1、ExcelWorkbook天加到form1中procedure TForm1.Button1Click(Sender: TObject);begin form1.ExcelApplication1.Connect; form1.ExcelApplication1.Visible[0]:=true; form1.ExcelWorkbook1.ConnectTo(form1.ExcelApplication1.Workbooks.Add(emptyparam,0));end; flyhot(阳光清晨): 我不太清楚,能详细点吗? http://expert.csdn.net/Expert/topic/1467/1467372.xml?temp=.8965113 看看ShellExecute可以的,我以前用过! xylyge(很想学好) 谢谢了! 在System页放一个OleConnected(好像这样写的)然后写代码OleConnected1.CreateObject('Word.Basic');OleConnected1.doVerd(-1);就搞定了 //打开Execel ExcelApplication1.Connect; ExcelApplication1.Visible[0]:=true; ExcelWorkBook1.ConnectTo(ExcelApplication1.Workbooks.Add(emptyparam,0)); //打开word WordApplication1.Connect; WordApplication1.Visible:=true; WordDocument1.ConnectTo(WordApplication1.Documents.add (emptyparam,emptyparam,emptyparam,emptyparam)); 在uses 加上winprocsvar x:cardinal;begin{启动控制面板}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL',9);{辅助选项 属性-键盘}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL access.cpl,,1',9);{辅助选项 属性-声音}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL access.cpl,,2',9);{辅助选项 属性-显示}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL access.cpl,,3',9);{辅助选项 属性-鼠标}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL access.cpl,,4',9);{辅助选项 属性-常规}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL access.cpl,,5',9);{添加/删除程序 属性-安装/卸载}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Appwiz.cpl,,1',9);{添加/删除程序 属性-Windows安装程序}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Appwiz.cpl,,2',9);{添加/删除程序 属性-启动盘}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Appwiz.cpl,,3',9);{显示 属性-背景}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0',9);{显示 属性-屏幕保护程序}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1',9);{显示 属性-外观}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2',9);{显示 属性-设置}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3',9);{Internet 属性-常规}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,0',9);{Internet 属性-安全}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,1',9);{Internet 属性-内容}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,2',9);{Internet 属性-连接}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,3',9);{Internet 属性-程序}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,4',9);{Internet 属性-高级}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,5',9);{区域设置 属性-区域设置}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Intl.cpl,,0',9);{区域设置 属性-数字}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Intl.cpl,,1',9);{区域设置 属性-货币}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Intl.cpl,,2',9);{区域设置 属性-时间}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Intl.cpl,,3',9);{区域设置 属性-日期}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Intl.cpl,,4',9);{游戏控制器-一般}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Joy.cpl,,0',9);{游戏控制器-高级}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Joy.cpl,,1',9);{鼠标 属性}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Main.cpl',9);{多媒体 属性-音频}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Mmsys.cpl,,0',9);{多媒体 属性-视频}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Mmsys.cpl,,1',9);{多媒体 属性-MIDI}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Mmsys.cpl,,2',9);{多媒体 属性-CD音乐}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Mmsys.cpl,,3',9);{多媒体 属性-设备}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Mmsys.cpl,,4',9);{调制解调器 属性}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Modem.cpl',9);{网络}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Netcpl.cpl',9);{密码 属性}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Password.cpl',9);{扫描仪与数字相机 属性}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Sticpl.cpl',9);{系统 属性-常规}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Sysdm.cpl,,0',9);{系统 属性-设备管理器}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Sysdm.cpl,,1',9);{系统 属性-硬件配置文件}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Sysdm.cpl,,2',9);{系统 属性-性能}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Sysdm.cpl,,3',9);{日期/时间 属性}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL timedate.cpl',9);{电源管理 属性}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Powercfg.cpl',9);{拨号属性}x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Telephon.cpl',9);{----------------------调用错误----------------------}if x=0 then messagebox(0,'程序超出内存','错误',0);if x=ERROR_BAD_FORMAT then messagebox(0,'该程序非一个合法的Win32.EXE程序).','错误',0);if x=ERROR_FILE_NOT_FOUND then messagebox(0,'指定文件没找到','错误',0);if x=ERROR_PATH_NOT_FOUND then messagebox(0,'指定路径没找到','错误',0);end;其中‘Pchar('rundll32 shell32,Control_RunDLL desk.cpl')’可以是文件的路径 cxTreeList的两个问题 Delphi如果处理.net(C#)返回的DataTable数据? 有关SelectDirectory的一个问题 VB代码改DELPHI在线等待急!!! 菜的无比,case of问题。 远程模块中函数的返回值或参数的返回值问题,在线关注。 delphi的轉義符 请注释一下 业务纪录的自动编号!!! 下载了一个delphi和office xp,后缀名为:.iso,怎么打开?(xieha) 神洲数码怎样? 怎么知道用ODBC连接的数据库系统和名称和版本?
从server中选择ExcelApplication1、ExcelWorkbook天加到form1中
procedure TForm1.Button1Click(Sender: TObject);
begin
form1.ExcelApplication1.Connect;
form1.ExcelApplication1.Visible[0]:=true;
form1.ExcelWorkbook1.ConnectTo(form1.ExcelApplication1.Workbooks.Add(emptyparam,0));
end;
可以的,我以前用过!
然后写代码
OleConnected1.CreateObject('Word.Basic');
OleConnected1.doVerd(-1);
就搞定了
ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=true;
ExcelWorkBook1.ConnectTo(ExcelApplication1.Workbooks.Add(emptyparam,0));
//打开word
WordApplication1.Connect;
WordApplication1.Visible:=true;
WordDocument1.ConnectTo(WordApplication1.Documents.add (emptyparam,emptyparam,emptyparam,emptyparam));
var x:cardinal;
begin
{启动控制面板}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL',9);
{辅助选项 属性-键盘}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL access.cpl,,1',9);
{辅助选项 属性-声音}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL access.cpl,,2',9);
{辅助选项 属性-显示}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL access.cpl,,3',9);
{辅助选项 属性-鼠标}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL access.cpl,,4',9);
{辅助选项 属性-常规}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL access.cpl,,5',9);
{添加/删除程序 属性-安装/卸载}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Appwiz.cpl,,1',9);
{添加/删除程序 属性-Windows安装程序}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Appwiz.cpl,,2',9);
{添加/删除程序 属性-启动盘}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Appwiz.cpl,,3',9);
{显示 属性-背景}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0',9);
{显示 属性-屏幕保护程序}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1',9);
{显示 属性-外观}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2',9);
{显示 属性-设置}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3',9);
{Internet 属性-常规}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,0',9);
{Internet 属性-安全}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,1',9);
{Internet 属性-内容}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,2',9);
{Internet 属性-连接}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,3',9);
{Internet 属性-程序}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,4',9);
{Internet 属性-高级}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Inetcpl.cpl,,5',9);
{区域设置 属性-区域设置}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Intl.cpl,,0',9);
{区域设置 属性-数字}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Intl.cpl,,1',9);
{区域设置 属性-货币}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Intl.cpl,,2',9);
{区域设置 属性-时间}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Intl.cpl,,3',9);
{区域设置 属性-日期}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Intl.cpl,,4',9);
{游戏控制器-一般}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Joy.cpl,,0',9);
{游戏控制器-高级}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Joy.cpl,,1',9);
{鼠标 属性}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Main.cpl',9);
{多媒体 属性-音频}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Mmsys.cpl,,0',9);
{多媒体 属性-视频}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Mmsys.cpl,,1',9);
{多媒体 属性-MIDI}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Mmsys.cpl,,2',9);
{多媒体 属性-CD音乐}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Mmsys.cpl,,3',9);
{多媒体 属性-设备}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Mmsys.cpl,,4',9);
{调制解调器 属性}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Modem.cpl',9);
{网络}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Netcpl.cpl',9);
{密码 属性}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Password.cpl',9);
{扫描仪与数字相机 属性}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Sticpl.cpl',9);
{系统 属性-常规}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Sysdm.cpl,,0',9);
{系统 属性-设备管理器}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Sysdm.cpl,,1',9);
{系统 属性-硬件配置文件}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Sysdm.cpl,,2',9);
{系统 属性-性能}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Sysdm.cpl,,3',9);
{日期/时间 属性}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL timedate.cpl',9);
{电源管理 属性}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Powercfg.cpl',9);
{拨号属性}
x:=winexec('rundll32.exe shell32.dll,Control_RunDLL Telephon.cpl',9);
{----------------------调用错误----------------------}
if x=0 then messagebox(0,'程序超出内存','错误',0);
if x=ERROR_BAD_FORMAT then messagebox(0,'该程序非一个合法的Win32.EXE程序).','错误',0);
if x=ERROR_FILE_NOT_FOUND then messagebox(0,'指定文件没找到','错误',0);
if x=ERROR_PATH_NOT_FOUND then messagebox(0,'指定路径没找到','错误',0);
end;
其中‘Pchar('rundll32 shell32,Control_RunDLL desk.cpl')’可以是文件的路径