converting pdf files to excel using microsoft word as the convertor

DarkGlobus1OO

New Member
Joined
Sep 28, 2017
Messages
11
i heard it is possible,sadly i didnt manage to achieve this function(the code either gives me an object error or goes to an infinite loop)
anyone done that before and can share his knowledge?
the code i tried:

Code:
Sub pdf_To_Excel_early_Binding()




Dim myWorksheet As Worksheet
Dim wordApp As Word.Application
Dim myWshShell As WshShell
Dim pathAndFileName As String
Dim registryKey As String
Dim wordVersion As String


Set myWorsheet = ActiveWorkbook.ActiveSheet


Set wordApp = New Word.Application
Set myWshShell = New WshShell


pathAndFileName = "the address of the pdf file"


wordVersion = wordApp.Version
registryKey = "HKCU\SOFTWARE\Microsoft\Office" & wordVersion & "\Word\Options"


myWshShell.RegWrite registryKey & "DisableConvertPdfWarning", 1, "REG_DWORD"


wordApp.Documents.Open _
 Filename:=pathAndFileName, _
 ConfirmConversions:=False
 
myWshShell.RegWrite registryKey & "DisableConvertPdfWarning", 0, "REG_DWORD"


wordApp.ActiveDocument.Content.Copy


With myWorksheet
 .Range("B4").Select
 .PasteSpecial Format:="Text"
End With


wordApp.Quit SaveChanges:=wdDoNotSaveChanges


Set wordApp = Nothing
Set myWshShell = Nothing


End Sub
 
Last edited by a moderator:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
It's not at all apparent why you're using Word for this or why you're messing with Registry values.
 
Upvote 0
im using word because its the only option i have, i need to write this code in a computer that has no access to the internet and pretty much only has microsoft office installed on it, from my understanding word 2013+ can convert pdf files to word,
im messing with the registery so i wont see the convertion alert, help would be much appreciated
 
Upvote 0
Did you try it with just:
wordApp.Documents.Open FileName:=pathAndFileName, ConfirmConversions:=False
or, alternatively, with:
Code:
Sub pdf_To_Excel_early_Binding()
Dim myWorksheet As Worksheet, wordApp As New Word.Application
Set myWorsheet = ActiveWorkbook.ActiveSheet
pathAndFileName = "the name & address of the pdf file"
With wordApp
  .DisplayAlerts = wdAlertsNone
  .Documents.Open FileName:=pathAndFileName, ConfirmConversions:=False
  With .ActiveDocument
    .Content.Copy
    myWorksheet.Range("B4").PasteSpecial Format:="Text"
    .Close False
  End With
  .DisplayAlerts = wdAlertsAll
  .Quit
End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,973
Messages
6,122,534
Members
449,088
Latest member
RandomExceller01

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