如何在excel列中打印名称为pdf的列表文件?

问题描述

enter image description here

我要打印在excel的1列中具有名称的列表pdf文件

我不想按住Ctrl键并在excel栏中一一找到它的名称,然后选择那些文件。因为可能有很多文件一个一个地找一个要花很多时间。

例如上图。

哪些软件可以支持我?还是必须做任何事情来解决这个问题?

感谢您阅读我的帖子!!!

解决方法

这应该有效:

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    ByVal hwnd As Long,ByVal lpOperation As String,ByVal lpFile As String,_
    ByVal lpParameters As String,ByVal lpDirectory As String,ByVal nShowCmd As Long) As Long
 
Public Function PrintPDF(xlHwnd As Long,FileName As String) As Boolean
    Dim X As Long
    
    On Error Resume Next
    X = ShellExecute(xlHwnd,"Print",FileName,0&,3)
    
    If Err.Number > 0 Then
        MsgBox Err.Number & ": " & Err.Description
        PrintPDF = False
    Else
        PrintPDF = True
    End If
    On Error GoTo 0
End Function
 
Sub PrintSpecificPDF()
    'opens the specified pdf and prints it using the default printer
    'note that it uses the default PDF program and leaves it open
    
    Dim strPth As String,strFile As String
    Dim rngList As Range,rngTarget As Range
    
    
    Set rngList = Range(Range("B2"),Range("B1").End(xlDown))
    strPth = "D:\PDF\"
    
    For Each rngTarget In rngList
        
        strFile = rngTarget.Value & ".pdf"
         
        If Not PrintPDF(0,strPth & strFile) Then
            MsgBox "Printing failed"
        End If
        
    Next
    
End Sub

我已经拿了这个code,并根据您的情况对其做了一些修改。