简体   繁体   English

VBA; 在现有的 PDF window 中打开 PDF(作为新标签)

[英]VBA; Open PDF in existing PDF window (as a new tab)

I am trying to use VBA to open a PDF in an existing Adobe Acrobat window.我正在尝试使用 VBA 在现有的 Adobe Acrobat window 中打开 PDF。

Currently, however, my code is opening the pdf in a separate Adobe window each time it is run.但是,目前,我的代码每次运行时都会在单独的 Adobe window 中打开 pdf。

End goal: VBA opens a PDF in an existing Adobe acrobat window in the form of a new PDF tab.最终目标:VBA 在现有的 Adobe acrobat window 中以新的 PDF 选项卡的形式打开 PDF。

Here is my code:这是我的代码:

Sub openPDF(sPath As String)

    Dim primaryDoc As Object, PrimaryAVDoc As Object, appAdobe As Object ' Open Adobe instance
    Dim zPath As String
    Dim adobeDoc As Variant, PDFPageView As Variant
    
    Set appAdobe = CreateObject("AcroExch.App")
    
    ' Create Adobe PDF object
    Set primaryDoc = CreateObject("AcroExch.PDDoc")
    
    Set PrimaryAVDoc = CreateObject("AcroExch.AVDoc")
    
    If PrimaryAVDoc.Open(sPath, "") = True Then
        PrimaryAVDoc.BringToFront
        Call PrimaryAVDoc.Maximize(True)
        Set PDFPageView = PrimaryAVDoc.GetAVPageView()
        ' Zoom (optional)
'        Call PDFPageView.ZoomTo(2, 50)
    End If
    
    Set primaryDoc = Nothing
    Set PrimaryAVDoc = Nothing
    Set appAdobe = Nothing
    
End Sub

Whilst heavily used by programmable graphics applications, generally:-虽然可编程图形应用程序大量使用,但通常:-

This is a user application setting (depending on version user interface) it is unlikely to be externally program related (but see note below).这是一个用户应用程序设置(取决于版本用户界面),不太可能与外部程序相关(但请参阅下面的注释)。 Each user installation, just like in a browser, has user settings/preferences and this is thus a user run time option.每个用户安装,就像在浏览器中一样,都有用户设置/偏好,因此这是一个用户运行时选项。 I am not going to install every version or yours just to prove your user version does or does not have the required setting.我不会安装每个版本或您的版本只是为了证明您的用户版本是否具有所需的设置。

在此处输入图像描述

Many PDF viewers have legacy and Tabbed mode options (often addressable via DDE in Windows or Pipes in other systems) that may or may not be externally addressable for reuse windows. Those that are SyncTeX Aware usually have widest range of settings for external IDE calls.许多 PDF 查看器具有传统和选项卡模式选项(通常可通过 Windows 中的 DDE 或其他系统中的 Pipes 寻址),这些选项可能是也可能不是外部可寻址的以供重用 windows。SyncTeX Aware 的那些通常具有最广泛的外部 IDE 调用设置。 Adobe is SyncTeX Aware but offers fewer choices. Adobe 是 SyncTeX Aware,但提供的选择较少。

Here the upper quartiles setting is open as separate windows.这里上四分位数设置单独打开windows。
Lower view all files are now opened in tabs mode.下视图所有文件现在都以选项卡模式打开。

在此处输入图像描述

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

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