CONVERT PDF TO WORD AND FROM PAGE NO 2 TILL END PAGE

deepak30

New Member
Joined
May 11, 2020
Messages
41
Office Version
  1. 2013
  2. 2007
Platform
  1. Windows
Hi

I excel macro I am auto converting PDF file to Word using foxit phantom pdf but thing is i want to convert pdf to word from PDF 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
VBA Code:
Sub ExtracPDFData()
Dim pdfapp, FileName As Variant
Dim PDFFolder, ExportFile As String
Dim ClientRow, CustCol, DataCol, DataRow, LastRow As Long
pdfapp = Shell("C:\Program Files\Foxit Software\Foxit PhantomPDF\FoxitPhantomPDF.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 Files\Foxit Software\Foxit PhantomPDF\FoxitPhantomPDF.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
[/CODE]
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Can you first delete page 1 before starting the conversion?
 
Upvote 0
Can you first delete page 1 before starting the conversion?
No Sir Its not possible to delete 1 page because i have to daily nearly 20 to 50 pdf that I have to convert and bring that pdf data in word then again transfer that data in my excel master file
 
Upvote 0
I don't know about foxit phantom pdf. With Acrobat, you can programmatically delete any page you want.
 
Upvote 0
I don't know about foxit phantom pdf. With Acrobat, you can programmatically delete any page you want.

Sir thanks for the reply I deleted the 1st page through application send key and succeeded but when I converted that pdf to word the some table column in word gets merged
and if I gave the command to convert from page 2 to last page it give me proper table

secondly 1st i had tried in acrobat but convertion is very poor as it merges some table column and i am not able to get required results so i went through foxit where I got the desire table result
 
Upvote 0
My last suggestion would be to convert the whole document to Word then delete from Word the first page.
 
Upvote 0
yes as per your comment i tried but same issue is coming column's get merged see the attachment ( Merge column problem) if i something different if gets merged and
if i convert from page 2 till last page then i get desire results (attachment merge column ok)
 

Attachments

  • merge column ok.png
    merge column ok.png
    172.5 KB · Views: 12
  • merge column problem.png
    merge column problem.png
    170.5 KB · Views: 12
Upvote 0
My last suggestion would be to convert the whole document to Word then delete from Word the first page.
Sir I got a temporary solution I manually gived the last page number of PDF file in a Cell "E9" and in macro i made little bit changes mention below

mnum = range("e9").value
Call SendKeys("2-" & mnun, true )

then converted and it worked
But only thing is that every now and then I have open a pdf look for last page number and enter it value in cell E9 and then convert it

Hope someone will answer my query if anyone can get automatic value of last page number in cell then that will be great
 
Upvote 0
yes as per your comment i tried but same issue is coming column's get merged see the attachment ( Merge column problem) if i something different if gets merged and
if i convert from page 2 till last page then i get desire results (attachment merge column ok)
Frankly, I cannot tell the difference.
 
Upvote 0
Sir I got a temporary solution I manually gived the last page number of PDF file in a Cell "E9" and in macro i made little bit changes mention below

mnum = range("e9").value
Call SendKeys("2-" & mnun, true )

then converted and it worked
But only thing is that every now and then I have open a pdf look for last page number and enter it value in cell E9 and then convert it

Hope someone will answer my query if anyone can get automatic value of last page number in cell then that will be great
I did a search on Foxit Phantom, it should have a quite powerful API. Did you study its documentation? I think it should be quite easy to programmatically get the page number of the last page though I don't know how.
 
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,941
Members
448,534
Latest member
benefuexx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top