Extracting PDF into Excel as text

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
I'm trying to use this example http://www.vbaexpress.com/kb/getarticle.php?kb_id=977 but get a Run-time error '75' Path/File access error on this line of the subroutine:

Code:
Sub ReadTextFile()
    Dim FileNum As Integer
    Dim r As Integer
    Dim wb As Workbook
    Dim Data As String
    r = 1
    FileNum = FreeFile
    Set wb = Workbooks.Add
[COLOR=#ff0000][B]    Open PageName For Input As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum]#FileNum[/URL] [/B][/COLOR]
    Do While Not EOF(FileNum)
        Line Input [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum]#FileNum[/URL] , Data
        ActiveSheet.Cells(r, 1) = Data
        r = r + 1
    Loop
    Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum]#FileNum[/URL] 
End Sub

It seems to create the YourPage pdf and txt file ok.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
You have not defined file path for the text file anywhere so it is erroring.
Code:
[B]Open [U][I]PageName[/I][/U] For Input As [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum"]#FileNum[/URL][/B]
PageName should be valid file name with a valid path e.g.
Code:
PageName = "C:\Temp\OutPutTextFile.txt"
[B]Open [U][I]PageName[/I][/U] For Input As [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum"]#FileNum[/URL][/B]
 
Upvote 0
You have not defined file path for the text file anywhere so it is erroring.
Code:
[B]Open [U][I]PageName[/I][/U] For Input As [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum"]#FileNum[/URL][/B]
PageName should be valid file name with a valid path e.g.
Code:
PageName = "C:\Temp\OutPutTextFile.txt"
[B]Open [U][I]PageName[/I][/U] For Input As [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum"]#FileNum[/URL][/B]

thanks, I'll give it a try
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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