我正在尝试将excel中的pdf列表转换为文本。我已经在2列中列出了两个文件名。我现在需要的是确保下面的代码从单元格中读取sfile
和dfile
,以便代码可以执行,然后循环以转换列中的所有文件。我无法正确地为这两条线做到这一点。有人可以帮忙吗?
提前谢谢!
sfile = ws("Sheet1").rng("A" & "row").Value
dfile = ws("Sheet1").rng("C" & "row").Value
Sub ConvertPDF()
Dim sfile As String, dfile As String
Dim AcroXApp As Acrobat.acroApp, AcroXAVDoc As Acrobat.AcroAVDoc
Dim AcroXPDDoc As Acrobat.AcroPDDoc, jsObj As Object, Row As Long
Dim ws As Worksheet
Dim rng As Range
Row = 2
sfile = ws("Sheet1").rng("A" & "row").Value
dfile = ws("Sheet1").rng("C" & "row").Value
Do While ws("Sheet1").Range("A" & "row") <> ""
Set AcroXApp = CreateObject("AcroExch.App")
'AcroXApp.Show
Set AcroXAVDoc = CreateObject("AcroExch.AVDoc")
AcroXAVDoc.Open sfile, "Acrobat"
Set AcroXPDDoc = AcroXAVDoc.GetPDDoc
Set jsObj = AcroXPDDoc.GetJSObject
jsObj.SaveAs dfile, "com.adobe.acrobat.plain-text"
AcroXAVDoc.Close False
AcroXApp.Hide
AcroXApp.Exit
Loop
Row = Row + 1
End Sub
答案 0 :(得分:0)
你可以像这样阅读细胞
sfile = ThisWorkbook.Worksheets("Sheet1").Range("A" & Row).Value
dfile = ThisWorkbook.Worksheets("Sheet1").Range("C" & Row).Value
使用工作表code name更好
sfile = Sheet1.Range("A" & Row).Value
dfile = Sheet1.Range("C" & Row).Value