excel vba 将word存为pdf格式,插入图片,设置透明度

word不支持对插入图片设置透明度,但可以插入一个绘图区域,文本框或者方形,然后设置底纹选择图片,然后对这个框来设置透明度

转换pdf文件

Sub mac()
' 
    ActiveDocument.ExportAsFixedFormat OutputFileName:="D:\Doc1.pdf", _
        ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
        wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
        Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
        CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
        BitmapMissingFonts:=True, UseISO19005_1:=False
End Sub
Sub gopdf()

  Application.DisplayAlerts = False
  Application.ScreenUpdating = False
Dim fDialog As FileDialog
  Set fDialog = Application.FileDialog(msoFileDialogFilePicker) '返回一个 FileDialog 对象,该对象代表文件对话框的单个实例。
Dim vrtSelectedItem As Variant
Dim wdDoc As Document
Dim showFolder As Boolean
  showFolder = False
  With fDialog
    .Filters.Add "Word文件", "*.doc;*.docx;*.docm", 1
    If .Show = -1 Then
      For Each vrtSelectedItem In .SelectedItems
        '如果选择了本文档则跳过
        If InStrRev(vrtSelectedItem, ThisDocument.Name) = 0 Then
          On Error Resume Next
          Set wdDoc = Application.Documents.Open(vrtSelectedItem, ReadOnly:=True)
          wdDoc.SaveAs Left(vrtSelectedItem, Len(vrtSelectedItem) - 5), wdFormatPDF
          wdDoc.Close False
        End If
      Next vrtSelectedItem
      If showFolder Then Call Shell("explorer.exe " & Left(fDialog.SelectedItems(1), _
         InStrRev(fDialog.SelectedItems(1), "")), vbMaximizedFocus)
    End If
  End With
  Set fDialog = Nothing
  Application.ScreenUpdating = True

  Application.DisplayAlerts = True

End Sub

© 2017, 新之助meow. 原创文章转载请注明: 转载自http://www.xinmeow.com

0.00 avg. rating (0% score) - 0 votes
点赞