简体   繁体   English

使用VBA的Word Doc中的PDF片段?

[英]PDF Snippets in Word Doc with VBA?

So I have this Word doc with a bunch of ActiveX buttons, and whenever one of the buttons is pressed, a corresponding image pops up in a userform. 所以我有一个带有一些ActiveX按钮的Word文档,每当按下其中一个按钮时,就会在用户窗体中弹出相应的图像。 It looks like this: 它看起来像这样:
在此输入图像描述

My problem is that each of the images that pops up is a screenshot of a portion of a PDF, but my users actually need to be able to select/copy the text presented. 我的问题是弹出的每个图像都是PDF的一部分的屏幕截图,但我的用户实际上需要能够选择/复制所呈现的文本。

Is there any good way to embed portions of a PDF file in a userform so that the text is select-able? 有没有什么好方法可以在用户表单中嵌入PDF文件的部分,以便文本可以选择? It shouldn't be edit-able, just select-able. 它不应该是可编辑的,只能选择。

Or, worst case scenario, what might be the easiest way to copy text from the PDF myself and format it onto a userform? 或者,最糟糕的情况是,自己从PDF复制文本并将其格式化为用户表单的最简单方法是什么?

Thanks! 谢谢!

I wouldn't recommend using the image control for this if you want user to select the text from pdf. 如果您希望用户从pdf中选择文本,我建议不要使用图像控件。

Do this. 做这个。

  1. Install Adobe Pdf Reader on your pc. 在您的电脑上安装Adobe Pdf Reader。
  2. Create a New Userform and place the AcroPDF1 and CommandButton control and you are done. 创建一个新的AcroPDF1并放置AcroPDF1CommandButton控件,你就完成了。

To Add the AcroPDF1 control see the screenshot 要添加AcroPDF1控件,请参阅屏幕截图

在此输入图像描述

Next, draw the control on the Userform and place a CommandButton on the form 接下来,在Userform上绘制控件并在窗体上放置一个CommandButton

This is how your userform might look. 这就是您的用户形式的外观。

在此输入图像描述

Put this code in the click event of the CommandButton1. 将此代码放在CommandButton1的单击事件中。

Option Explicit

Private Sub CommandButton1_Click()
    '~~> Change filename as applicable
    AcroPDF1.LoadFile "C:\Sample.Pdf"
End Sub

Now when you run it, the pdf will be displayed and you can select text. 现在,当您运行它时,将显示pdf,您可以选择文本。 See screenshot below. 见下面的截图。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM