以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]外部引用msword问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=128107)

--  作者:witkeylaw
--  发布时间:2018/11/28 22:48:00
--  [求助]外部引用msword问题
1、批量设置图片大小,红色部分出错,请问如何处理。
2、代码
Dim app As New MSWord.Application
try

Dim fileName = "E:\\test.docx"
Dim doc As object = app.Documents.Open(fileName)

Dim ishape As msword.InlineShape
For Each ishape In app.ActiveDocument.InlineShapes
\' ishape.LockAspectRatio = msoCTrue
\' If ishape.Type = msword.wdInlineShapePicture Then

If ishape.height > 400

ishape.height = 450

Else


If ishape.Width > 250 Then

ishape.Width = 480
Else
ishape.Width = 238
End If
End If
\' End If
Next
MsgBox("done")


app.visible = True
catch ex As exception
msgbox(ex.message)
app.Quit
finally

End try


--  作者:有点甜
--  发布时间:2018/11/28 23:40:00
--  

参考

 

Dim app As New MSWord.Application
try
    Dim doc = app.Documents.Open("d:\\test.doc")
    For Each shape As object In doc.InlineShapes
        If shape.Type = MSWord.WdInlineShapeType.wdInlineShapePicture

            system.threading.thread.sleep(50)
            shape.ConvertToShape
        End If
    Next
    doc.saved = True
    app.visible = True
catch ex As exception
    msgbox(ex.message)
    app.Quit
finally
   
End try


--  作者:witkeylaw
--  发布时间:2018/12/15 16:35:00
--  
谢谢