VB如何将picturebox中生成的图片插入到word报告的指定位置 20
我利用vb画出的图在picture中,想直接导入到一个word报告的指定位置,请问代码如何?现在已经可以把文字导入到指定位置了,不知道图片怎么倒,求大神!,已写出代码如下...
我利用vb画出的图在picture中,想直接导入到一个word报告的指定位置,请问代码如何?现在已经可以把文字导入到指定位置了,不知道图片怎么倒,求大神!,已写出代码如下
Dim wdapp As Word.Application
Dim wddoc As Word.Document
Dim wdrange As Word.Range
Dim wdselect As Word.Selection
Dim wdtable As Word.Table
On Error Resume Next
Set wdapp = CreateObject("word.application")
Set wddoc = wdapp.Documents.Open(App.Path & "\单层梁.doc")
Set wdrange = wddoc.Range(Start:=0, End:=0)
wddoc.Activate
wdapp.Visible = True
wddoc.Bookmarks("左支反力").Range.Text = fr11
wddoc.Bookmarks("右支反力").Range.Text = fr12
wddoc.Bookmarks("剪力").Range.Text = Fsmax
wddoc.Bookmarks("弯矩").Range.Text = Mzmax
wddoc.Bookmarks("应力").Range.Text = o
wddoc.Bookmarks("挠度").Range.Text = Vmax
wddoc.Bookmarks("长度").Range.Text = l
wddoc.Bookmarks("活动铰支").Range.Text = b
wddoc.Bookmarks("挠度位置").Range.Text = cc
wddoc.Bookmarks("截面类型").Range.Text = Combo1.Text
wddoc.Bookmarks("惯性矩").Range.Text = i
wddoc.Bookmarks("弯曲截面模量").Range.Text = Wz
wddoc.Bookmarks("型号").Range.Text = Combo2.Text
wddoc.Bookmarks("固定铰支").Range.Text = a
dc = dc + 1
wddoc.SaveAs2 (App.Path & "\单层梁 " & dc & ".doc")
wddoc.Close
wdapp.Quit 展开
Dim wdapp As Word.Application
Dim wddoc As Word.Document
Dim wdrange As Word.Range
Dim wdselect As Word.Selection
Dim wdtable As Word.Table
On Error Resume Next
Set wdapp = CreateObject("word.application")
Set wddoc = wdapp.Documents.Open(App.Path & "\单层梁.doc")
Set wdrange = wddoc.Range(Start:=0, End:=0)
wddoc.Activate
wdapp.Visible = True
wddoc.Bookmarks("左支反力").Range.Text = fr11
wddoc.Bookmarks("右支反力").Range.Text = fr12
wddoc.Bookmarks("剪力").Range.Text = Fsmax
wddoc.Bookmarks("弯矩").Range.Text = Mzmax
wddoc.Bookmarks("应力").Range.Text = o
wddoc.Bookmarks("挠度").Range.Text = Vmax
wddoc.Bookmarks("长度").Range.Text = l
wddoc.Bookmarks("活动铰支").Range.Text = b
wddoc.Bookmarks("挠度位置").Range.Text = cc
wddoc.Bookmarks("截面类型").Range.Text = Combo1.Text
wddoc.Bookmarks("惯性矩").Range.Text = i
wddoc.Bookmarks("弯曲截面模量").Range.Text = Wz
wddoc.Bookmarks("型号").Range.Text = Combo2.Text
wddoc.Bookmarks("固定铰支").Range.Text = a
dc = dc + 1
wddoc.SaveAs2 (App.Path & "\单层梁 " & dc & ".doc")
wddoc.Close
wdapp.Quit 展开
3个回答
展开全部
'替换图片
Sub pic(ByVal img As Image, ByVal czp As String)
Clipboard.Clear() '清空剪贴板
Clipboard.SetImage(img) '把PictureBox1.Image图片放到剪贴板
WDAPP.Selection.Find.ClearFormatting()
WDAPP.Selection.Find.Replacement.ClearFormatting()
With WDAPP.Selection.Find
.Text = czp '要替换的字符
.Replacement.Text = "^c" '替换成PictureBox1.Image里的图片
.Forward = True
.Wrap = 1
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
WDAPP.Selection.Find.Execute(Replace:=2)
End Sub
Sub pic(ByVal img As Image, ByVal czp As String)
Clipboard.Clear() '清空剪贴板
Clipboard.SetImage(img) '把PictureBox1.Image图片放到剪贴板
WDAPP.Selection.Find.ClearFormatting()
WDAPP.Selection.Find.Replacement.ClearFormatting()
With WDAPP.Selection.Find
.Text = czp '要替换的字符
.Replacement.Text = "^c" '替换成PictureBox1.Image里的图片
.Forward = True
.Wrap = 1
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
WDAPP.Selection.Find.Execute(Replace:=2)
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我想我可以做一个例子给你。
追问
感谢,可以把例子的源代码发上来嘛?
另外我刚刚又搞了一下,分步可以把picturebox中的图片先保存出来,再插入到了word里,但还是没办法放到指定的位置。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询