51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 4224|回复: 1
打印 上一主题 下一主题

[原创] QTP中,判断 excel文件是否存在,不存在,新建一个。能实现吗?怎么实现?

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2005-7-21 14:53:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
QTP中,判断 excel文件是否存在,不存在,新建一个。能实现吗?怎么实现?

请各位大侠帮忙,谢谢。
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2005-7-22 09:23:20 | 只看该作者
好像贴过了吧?看来整理论坛是当务之急 啊。呵呵。更多的例子,请参考QTP plus的帮助文件。

  1. dim oFSO

  2. ' creating the file system object

  3. set oFSO = CreateObject ("Scripting.FileSystemObject")



  4. 'Option Explicit

  5. ' *********************************************************************************************

  6. ' Create a new txt file



  7. ' Parameters:

  8. ' FilePath - location of the file and its name

  9. ' *********************************************************************************************

  10. Function CreateFile (FilePath)

  11.     ' varibale that will hold the new file object

  12.     dim NewFile

  13.     ' create the new text ile

  14.     set NewFile = oFSO.CreateTextFile(FilePath, True)

  15.     set CreateFile = NewFile

  16. End Function



  17. ' *********************************************************************************************

  18. ' Check if a specific file exist



  19. ' Parameters:

  20. ' FilePath - location of the file and its name

  21. ' *********************************************************************************************

  22. Function CheckFileExists (FilePath)

  23.     ' check if file exist

  24.     CheckFileExists = oFSO.FileExists(FilePath)

  25. End Function
复制代码

[ Last edited by lovetest6 on 2005-7-22 at 09:25 ]
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-10-6 18:27 , Processed in 0.088930 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表