vb.net word文档的复制粘贴

ElaineZL 2008-11-13 09:37:34
我想实现点击button1按钮,将电脑里已经存在的word文档打开,关闭后,再点击button2使这个文档复制到相应的路径中,各位高手帮忙呀。。。
...全文
330 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
ElaineZL 2008-11-14
  • 打赏
  • 举报
回复
嘿嘿。。。非常感谢
ElaineZL 2008-11-13
  • 打赏
  • 举报
回复
恩,也是文件的复制粘贴,具体怎样实现啊?能给具体代码吗?
yanlongwuhui 2008-11-13
  • 打赏
  • 举报
回复
文件的复制粘贴? io.File.Copy
一只熊猫 2008-11-13
  • 打赏
  • 举报
回复
if nfo.ShowDialog()= Windows.Forms.DialogResult.OK then

nfo 改成 opendoc

一只熊猫 2008-11-13
  • 打赏
  • 举报
回复
要想打开word文档,首引你要在引用中添加 Microsoft Word 11.0 Object Library。




Imports Microsoft.Office.Interop

private sub opendoc()
dim opendoc as new openfiledialog
opendoc.Filter = "(*.Doc)|*.Doc"
opendoc.DefaultExt = "*.Doc"
if nfo.ShowDialog()= Windows.Forms.DialogResult.OK then
Dim wrdApp As New Microsoft.Office.Interop.Word.Application
Dim wrdDoc As Microsoft.Office.Interop.Word.Document
wrdapp.Visible=true
wrdDoc = wrdApp.Documents.Open(opendoc.filename)
end if
end sub

ElaineZL 2008-11-13
  • 打赏
  • 举报
回复
终于对了呢,还有打开一个WORD文档怎样实现的呢?用openfiledialog哦。。。
ElaineZL 2008-11-13
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 lizhengnan 的回复:]
不太明白.


VB.NET code
Dim strSource As string="原文件路径"
Dim strDest As string="C:\" & TextBox1.Text

system.IO.File.Copy(strSource ,strDest )




把文件复制到C盘,文件名为TextBox1.Text中的文件名
[/Quote]
是原文件名是改变的,文件名放在textbox1中
lizhengnan 2008-11-13
  • 打赏
  • 举报
回复
不太明白.


Dim strSource As string="原文件路径"
Dim strDest As string="C:\" & TextBox1.Text

system.IO.File.Copy(strSource ,strDest )


把文件复制到C盘,文件名为TextBox1.Text中的文件名


ElaineZL 2008-11-13
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 lizhengnan 的回复:]
Dim strSource As string="原文件路径"
Dim strDest As string="目标文件路径"

system.IO.File.Copy(strSource ,strDest )
[/Quote]
不对哦,strDest必须是目标文件的名称,不能是现有文件或目录啊,我是想把文件粘贴在一个空的文件夹中的,因为每次保存文件名是会改变的,所以我把文件名存在了textbox中,在窗体中可以手动改的
lizhengnan 2008-11-13
  • 打赏
  • 举报
回复
Dim strSource As string="原文件路径"
Dim strDest As string="目标文件路径"

system.IO.File.Copy(strSource ,strDest )

16,717

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧