首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Word .doc中使用VBA阻止图像打印

在Word .doc中使用VBA阻止图像打印
EN

Stack Overflow用户
提问于 2012-05-22 07:19:24
回答 3查看 3.4K关注 0票数 0

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

很大程度上,我只是希望我的Word文档不打印图像或水印,而不让打印它的人设置任何东西。(不必两者都有)

EN

回答 3

Stack Overflow用户

发布于 2012-05-22 07:57:41

你真的需要VBA来做这个吗?

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

单击文件|选项

您将看到一个"Word选项“对话框。

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

票数 1
EN

Stack Overflow用户

发布于 2013-01-18 07:19:05

不知道为什么,但这个男人工作得很好。

代码语言:javascript
复制
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

干杯mARTin

票数 0
EN

Stack Overflow用户

发布于 2013-01-30 00:24:26

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

代码语言:javascript
复制
Sub ShowHideLogoInHeader

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

代码语言:javascript
复制
On Local Error GoTo ErrHandler

暗淡的形状范围

代码语言:javascript
复制
Dim myStory As ShapeRange
Set myStory = ActiveDocument.StoryRanges(wdFirstPageHeaderStory).ShapeRange
myStory.Visible = Not myStory.Visible

Exit Sub

ErrHandler: debug中报告错误(独立函数)

代码语言:javascript
复制
ReportError "modRibbon - ToonOfVerbergLogo"
Err.Clear
End Sub
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10693859

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档