Forum

Convert PDF to Word
 
Notifications
Clear all

Convert PDF to Word

3 Posts
1 Users
0 Reactions
254 Views
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
Topic starter
 

Hello Sir

I have one problem and i am not able to find the solution

In excel vba I am auto converting PDF file to Word using foxit phantom pdf but thing is i want to convert pdf to word from page 2 till the end page

I am not able to get how to find the last page number of pdf and bring the value in vba 

below is my code where i have mention call send key ("2-100 ",true) but that is not working because many how many pages will be there in pdf i do not know so  can any one help me please

 

Sub ExtracPDFData()
Dim pdfapp, FileName As Variant
Dim PDFFolder, ExportFile As String
Dim ClientRow, CustCol, DataCol, DataRow, LastRow As Long
pdfapp = Shell("C:Program FilesFoxit SoftwareFoxit PhantomPDFFoxitPhantomPDF.exe", vbNormalFocus)
With Sheet1
If Sheet1.Range("c6").Value = Empty Then
MsgBox "Please Select your PDF File"
Exit Sub
End If
ExportFile = .Range("c6").Value
FileName = ExportFile
PDFFolder = Left$(FileName, InStrRev(FileName, ""))
End With

' CALL PATH NAME FROM SHEET1 C6 CELL
pdfapp = Shell("C:Program FilesFoxit SoftwareFoxit PhantomPDFFoxitPhantomPDF.exe """ & FileName & """", vbNormalFocus)
On Error Resume Next
AppActivate (pdapp)
On Error GoTo 0
Application.Wait Now + 0.0001
Application.SendKeys "%k", True
Application.Wait Now + 0.00001
Application.SendKeys "{home}", True
Application.Wait Now + 0.00001
'Call SendKeys(PDFFolder, True)
Application.SendKeys "%g", True
Application.Wait Now + 0.000001
Application.SendKeys "%p", True
Application.Wait Now + 0.000001
Application.SendKeys "{tab}", True
Application.Wait Now + 0.000001
Call SendKeys("2-100", True)
Application.SendKeys "%p", True
Application.Wait Now + 0.000001
Application.SendKeys "%k", True
Application.Wait Now + 0.000001
Application.SendKeys "%s", True
Application.Wait Now + 0.000001
Application.SendKeys "%y", True
Application.Wait Now + 0.000001
Application.SendKeys "{NUMLOCK}%s"
Application.Wait Now + 0.000001
End Sub

 
Posted : 16/06/2020 7:15 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
Topic starter
 

Hi Deepak,

Please review the forum rules and guidelines

https://www.myonlinetraininghub.com/excel-forum/forum-rules-and-guides/read-this-first

When you have a new question please start a new topic, don't post onto the end of an existing thread.

Regards

Phil

 
Posted : 17/06/2020 9:18 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
Topic starter
 

Hi Deepak,

I can't really test this without Foxit.

But why not just convert the whole PDF then delete the first page in Word?

See attached.  You'll need to set a reference to the Microsoft Word Object Library in Tools -> References in the VBA Editor.

Phil

 
Posted : 19/06/2020 8:14 pm
Share: