【问题标题】:Using VBA to prevent image printing in Word .doc使用 VBA 防止 Word 中的图像打印 .doc
【发布时间】:2019-05-25 18:55:10
【问题描述】:

我设置了一份背景为 8.5 x 11 图像的简历(如果需要,可以将其设置为水印)。现在我想设置它,这样它就不会自动打印背景图像,这样雇主就不必费劲了。在网上查看后,我注意到这可能是必须使用 VBA 和模板设置的东西。任何现场或任何愿意解决这个问题的人都将不胜感激。

几乎我只是希望我的 Word 文档不打印图像或水印,而无需让打印它的人进行任何设置。(不必两者兼而有之)

【问题讨论】:

  • 嗯 - 我不会在简历中启用宏,如果我收到一份包含宏的简历,我什至可能不愿意先看一看。
  • 要明确一点——我不想在这里刻薄:任何审查简历的人都可能至少要查看十几个,所以他们不想花时间尝试弄清楚你简历中的宏在启用它之前做了什么......
  • 蒂姆,一个人会因为不想处理打印而忽略具有设计背景的简历吗?(顺便说一句,我将申请艺术职位)
  • 我更喜欢纯色背景,但我离艺术领域的距离还很远……

标签: vba ms-word


【解决方案1】:

你真的需要 VBA 吗?

要在 Word 2010 中禁用背景颜色和图像的打印,只需按照以下步骤操作

点击文件 |选项

您将获得一个“单词选项”对话框。

在显示选项卡下,只需取消选中“打印背景颜色和图像”

【讨论】:

  • 它是在 photoshop 中创建的自定义背景图像,所以我通过使用图像来伪造背景部分,所以这不起作用。如前所述,需要打印此文件的人必须采取我不想要的这些步骤。
  • 在这种情况下给他发 2 份简历。一个用于观看乐趣,另一个用于打印。我同意@Tim Williams 的观点,即简历中的宏肯定会产生问题。
【解决方案2】:

我使用以下(简短)程序作为功能区扩展,用于在文档标题中显示/隐藏徽标,以便用户可以在创建打印/pdf 之前进行切换。

Sub ShowHideLogoInHeader

本地错误处理程序(非关键)

On Local Error GoTo ErrHandler

模糊的形状范围

Dim myStory As ShapeRange
Set myStory = ActiveDocument.StoryRanges(wdFirstPageHeaderStory).ShapeRange
myStory.Visible = Not myStory.Visible

Exit Sub

错误处理程序: 调试中报错(单独函数)

ReportError "modRibbon - ToonOfVerbergLogo"
Err.Clear
End Sub

【讨论】:

    【解决方案3】:

    不知道为什么,但这似乎可以正常工作。

    Public WithEvents appWord As Word.Application
    
    Private Sub Document_Open()
        Set appWord = Application
        ' Not sure if your image is a shape or inlineshape, so...
        If ThisDocument.Shapes.Count Then
            ' First Shape is now visible
            ThisDocument.Shapes(1).Visible = msoTrue
        ElseIf ThisDocument.InlineShapes.Count Then
            ' First inlineshpae has medium brightness
            ThisDocument.InlineShapes.Item(1).PictureFormat.Brightness = 0.5
        End If
    End Sub
    
    Private Sub appWord_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
    
     Dim intResponse As Integer
    
     intResponse = MsgBox("This document contains a background image. " & _
        "Would you like to hide it before printing?", vbYesNo, _
        "Hide Background Image?")
         If intResponse = vbYes Then
             hide_images
    
         ElseIf intResponse = vbNo Then
    
            show_images
         End If
    End Sub
    
    Sub hide_images()
    
        Application.DisplayStatusBar = True
        With ActiveWindow
            .DisplayHorizontalScrollBar = True
            .DisplayVerticalScrollBar = True
            .DisplayLeftScrollBar = False
            .StyleAreaWidth = CentimetersToPoints(0)
            .DisplayVerticalRuler = True
            .DisplayRightRuler = False
            .DisplayScreenTips = True
            With .View
                .ShowAnimation = True
                .Draft = False
                .WrapToWindow = False
                .ShowPicturePlaceHolders = False
                .ShowFieldCodes = False
                .ShowBookmarks = False
                .FieldShading = wdFieldShadingWhenSelected
                .ShowTabs = False
                .ShowSpaces = False
                .ShowParagraphs = False
                .ShowHyphens = False
                .ShowHiddenText = False
                .ShowAll = True
                .ShowDrawings = True
                .ShowObjectAnchors = False
                .ShowTextBoundaries = False
                .ShowHighlight = True
            End With
        End With
        With Options
            .UpdateFieldsAtPrint = False
            .UpdateLinksAtPrint = False
            .DefaultTray = "Druckereinstellungen verwenden"
            .PrintBackground = True
            .PrintProperties = False
            .PrintFieldCodes = False
            .PrintComments = False
            .PrintHiddenText = False
            .PrintDrawingObjects = False
            .PrintDraft = False
            .PrintReverse = False
            .MapPaperSize = True
        End With
        With ActiveDocument
            .PrintPostScriptOverText = False
            .PrintFormsData = False
        End With
    End Sub
    
    Sub show_images()
    
        With Options
            .UpdateFieldsAtPrint = False
            .UpdateLinksAtPrint = False
            .DefaultTray = "Druckereinstellungen verwenden"
            .PrintBackground = True
            .PrintProperties = False
            .PrintFieldCodes = False
            .PrintComments = False
            .PrintHiddenText = False
            .PrintDrawingObjects = True
            .PrintDraft = False
            .PrintReverse = False
            .MapPaperSize = True
        End With
        With ActiveDocument
            .PrintPostScriptOverText = False
            .PrintFormsData = False
        End With
    End Sub
    

    干杯 马丁

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-11
      • 2022-11-13
      • 2020-04-10
      • 2015-12-17
      • 1970-01-01
      相关资源
      最近更新 更多