使用VBA防止Word .doc中的图像打印

时间:2012-05-21 23:19:24

标签: vba ms-word

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

我只是希望我的Word文档不打印图像或水印而不打印它的人设置任何东西。(不一定是两者)

3 个答案:

答案 0 :(得分:1)

你真的需要VBA吗?

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

即可

单击文件|选项

您将获得一个" Word选项"对话框。

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

答案 1 :(得分:0)

不知道为什么,但这个工作正常。

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

干杯 马丁

答案 2 :(得分:0)

我使用以下(简短)程序作为功能区扩展,用于在文档标题中显示/隐藏徽标,以便用户可以在创建print / 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

ErrHandler: 在调试中报告错误(单独的函数)

ReportError "modRibbon - ToonOfVerbergLogo"
Err.Clear
End Sub
相关问题