如何转换由VBScript调用OCX的语法? ( 积分: 100 )

  • 主题发起人 主题发起人 newjq
  • 开始时间 开始时间
N

newjq

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟是第一次调用OCX控件,
这个控件在VBScript调用语法是这样的:
VBScript:
dim DllWord
set DllWord = CreateObject("WordDll.clsWord")
DllWord.OpenFileName = "D:/1.doc"
DllWord.SaveFileName = "D:/1.doc"
DllWord.UserName = "王刚"
DllWord.ActionState = 0
DllWord.SaveLocalState = True
DllWord.SaveLocalFileName = "D:11.doc"
DllWord.Run

我转换成DELPHI
DLEPHI:
DllWord: Variant;
try
DllWord := CreateOleObject('WordDll.clsWord');
except
exit;
end;
try
DllWord.OpenFileName := 'D:/1.doc';
DllWord.SaveFileName := 'D:/1.doc';
DllWord.UserName := '王刚';
DllWord.ActionState := '0';
DllWord.SaveLocalState := True;
DllWord.SaveLocalFileName := 'D:11.doc';
DllWord.Run;
except
DllWord.quit;
exit;
end;

运行到 DllWord.Run时出错!请大侠们帮忙啊!!!
出错信息为:
Protection Error
Debugger detected - please close it down and restart!

Windows NT user: Please note that having the
WinIce/SoftIce service installed means that you are
runngin a debugger!
 
小弟是第一次调用OCX控件,
这个控件在VBScript调用语法是这样的:
VBScript:
dim DllWord
set DllWord = CreateObject("WordDll.clsWord")
DllWord.OpenFileName = "D:/1.doc"
DllWord.SaveFileName = "D:/1.doc"
DllWord.UserName = "王刚"
DllWord.ActionState = 0
DllWord.SaveLocalState = True
DllWord.SaveLocalFileName = "D:11.doc"
DllWord.Run

我转换成DELPHI
DLEPHI:
DllWord: Variant;
try
DllWord := CreateOleObject('WordDll.clsWord');
except
exit;
end;
try
DllWord.OpenFileName := 'D:/1.doc';
DllWord.SaveFileName := 'D:/1.doc';
DllWord.UserName := '王刚';
DllWord.ActionState := '0';
DllWord.SaveLocalState := True;
DllWord.SaveLocalFileName := 'D:11.doc';
DllWord.Run;
except
DllWord.quit;
exit;
end;

运行到 DllWord.Run时出错!请大侠们帮忙啊!!!
出错信息为:
Protection Error
Debugger detected - please close it down and restart!

Windows NT user: Please note that having the
WinIce/SoftIce service installed means that you are
runngin a debugger!
 
脱离环境运行看看,就是不要在Delphi里面运行,直接执行你编译的可执行文件,上面的意思好像是在说你在运行调试器
 
感谢chenybin,脱离环境运行就可以了!
我再问一个问题:
上面这种调用方式和
菜单component|install activeX Control..找到ocx文件,Ok后再Install...
有什么区别啊?
我看到生成的Unit文件中根本没有上面的这些属性和方法!
 
封装了一下,好用一点,本质都还是要调用的,install以后可以使用delphi的那个代码完成功能,记得给分哦:)
 
接受答案了.
 
封装了一下,好用一点,本质都还是要调用的,install以后可以使用delphi的那个代码完成功能,记得给分哦:)
 
后退
顶部