如何将WORD文档的每一页保存为图片

Dickson 2008-11-30 12:19:48
如何将WORD文档的每一页保存为图片
...全文
3227 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dickson 2008-12-01
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 duyin2004 的回复:]
很简单
picture1.printer a(i)应该改成picture1.print a(i)
打开文件,每一行送数组,计算picture1高度(可以打印多少行),picture1.print a(i) 统计a(i)总数/可以打印多少行,统计出多少页,想打印哪页,就打印数组的范围即可,然后保存成图片文件.
Picture1.CurrentY可以决定打印当前的位置.
[/Quote]

没太明白,有代码么?
_l_ 2008-12-01
  • 打赏
  • 举报
回复
费哪精神干什么
很多机器上默认安装有 Microsoft Office Document Image Writer 打印机
可以直接打印成TIF文件
xielang127 2008-12-01
  • 打赏
  • 举报
回复
我看了你的代码。。。。。 有个问题。。。
Dim stringDoc = wordDoc.Range.Text 这能通过吗?????

还有是不是要引用什么 你没写出来 。。。 不然 NEW Microsoft.Office.Interop.Word.Application == 是不能通过。。。。
xielang127 2008-12-01
  • 打赏
  • 举报
回复
我也试了你的代码 不通

单击Command1时 总是跳到gg: MsgBox "请在text2内输入页数,不要超过总页数": Exit Sub 这里 。。。。。 你检查检查 哪里是不是错了 。。。 何者 哪里 有什么要注意的 你没提出来 而使 代码不通。。。
duyin2004 2008-12-01
  • 打赏
  • 举报
回复
很简单
picture1.printer a(i)应该改成picture1.print a(i)
打开文件,每一行送数组,计算picture1高度(可以打印多少行),picture1.print a(i) 统计a(i)总数/可以打印多少行,统计出多少页,想打印哪页,就打印数组的范围即可,然后保存成图片文件.
Picture1.CurrentY可以决定打印当前的位置.
duyin2004 2008-12-01
  • 打赏
  • 举报
回复
打开文件,每一行送数组,计算picture1高度(可以打印多少行),picture1.printer a(i) 统计a(i)总数/可以打印多少行,统计出多少页,想打印哪页,就打印数组的范围即可,然后保存成图片文件.
Dickson 2008-12-01
  • 打赏
  • 举报
回复
没反应呀
duyin2004 2008-12-01
  • 打赏
  • 举报
回复
补充下
将p1属性中AutoRedraw设置成True 在属性设置即可 如果是false无法保存成图片
duyin2004 2008-12-01
  • 打赏
  • 举报
回复
你试试吧
Dim a() As String * 200
Dim i As Integer

Private Sub Command1_Click() '50行一页存到p1 图形框中
On Error GoTo gg
Dim kk As Integer
For kk = 1 + (Val(Text2.Text) - 1) * 50 To 50 * Val(Text2.Text) 'text2.text 为要存到图片上的当前页数,如输入1,2,3页
ReDim Preserve a(50)
P1.Print a(kk)
Next kk
Exit Sub
gg: MsgBox "请在text2内输入页数,不要超过总页数": Exit Sub
End Sub

Private Sub Command2_Click() '保存到图片文件

On Error GoTo gg

C1.CancelError = True
C1.FileName = ""
C1.Filter = "(*.bmp)|*.bmp"
C1.Action = 2

SavePicture P1.Image, C1.FileName
gg: Exit Sub
End Sub

Private Sub Command3_Click() '打开文件,送数组a(i),i 为文件总行数
On Error GoTo gg
C1.CancelError = True
C1.Flags = cdlOFNHideReadOnly Or cdlOFNOverwritePrompt
C1.Filter = "(*.txt)|*.txt|(*.doc)|*.doc|(All*.*)|*.*"
C1.DialogTitle = "文件打开" & Date & Time
C1.Action = 1
Open C1.FileName For Input As #1
Do While Not EOF(1)
ReDim Preserve a(i)
Line Input #1, a(i)

i = i + 1
Loop
Close #1
Text1.Text = i \ 50 + 1 '打开的总页数送text1.text显示,以50行为例,也可以是别的,具体你的p1依次可以显示多少行,相应该就可以
gg: Exit Sub
End Sub

Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
End Sub
其中p1为picturebox ,c1为commondialog 工程部件中添加microsot common dialog control 6.0
Dickson 2008-11-30
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 tjficcbw 的回复:]
你打开WORD,读取内容,到picture控件,存储为图片就行了
[/Quote]

只能获得第一页啊。。。怎么获得其他页数呢?
Dickson 2008-11-30
  • 打赏
  • 举报
回复
楼上的没有复制成图片啊
tjficcbw 2008-11-30
  • 打赏
  • 举报
回复
你打开WORD,读取内容,到picture控件,存储为图片就行了
tjficcbw 2008-11-30
  • 打赏
  • 举报
回复

Dim wordApp As New Microsoft.Office.Interop.Word.Application
Dim wordDoc As New Microsoft.Office.Interop.Word.Document
wordDoc = wordApp.Documents.Open(DirListBox1.Path & "\" & fileArrayComList(i, 0)) '打开文件并赋予文件实例
If Err.Number = 462 Then
wordApp = CreateObject("Word.Application") '建立WORD实例
wordDoc = wordApp.Documents.Open(DirListBox1.Path & "\" & fileArrayComList(i, 0)) '打开文件并赋予文件实例
End If

Dim stringDoc = wordDoc.Range.Text
Do While InStr(stringDoc, Chr(10) & Chr(13)) > 0
stringDoc = stringDoc.replace(Chr(13), "<br><br>  ")
Loop
stringDoc = stringDoc.replace("    ", "  ")
stringDoc = stringDoc.replace(" ", "")
stringDoc = stringDoc.replace("'", "‘")
'MsgBox(stringDoc)
wordDoc.Close() '关闭文档实例
wordApp.Quit()
wordDoc = Nothing
wordApp = Nothing






'模块代码
Type docit
name As String
paragraph As Long
allcount As Long
reblank As Long
resign As Long
End Type
'主程序代码
Dim itemDoc As docit
Dim stringDoc As String
Dim k As Integer
Dim wordCount()
Dim wordApp As New Word.Application
Dim wordDoc As New Word.Document
Dim wordArange As Word.Range
Dim wordSelection As Word.Selection
Dim ReplaceSign As Boolean


's为文件名及地址
On Error Resume Next
Set wordDoc = wordApp.Documents.Open(s) '打开文件并赋予文件实例
If Err.Number = 462 Then
Set wordApp = CreateObject("Word.Application") '建立WORD实例
Set wordDoc = wordApp.Documents.Open(s) '打开文件并赋予文件实例
End If
On Error GoTo ss
'itemDoc.name = wordDoc.Words.Parent
stringDoc = wordDoc.Range.Text
itemDoc.paragraph = 0
itemDoc.allcount = Len(stringDoc)
wordDoc.Close '关闭文档实例



tjficcbw 2008-11-30
  • 打赏
  • 举报
回复
打开读取不就是全体吗,为什么要读取第一页呢

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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