Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 06-09-2012, 10:50 AM
tinfanide tinfanide is offline Error: Input past end of file Windows 7 64bit Error: Input past end of file Office 2010 32bit
Expert
Error: Input past end of file
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Code:
Sub pdf()

Const sFile As String = "C:\test\1.pdf"

Dim f As Integer
Dim byt As Byte
Dim str As String, str1 As String

f = FreeFile
Open sFile For Binary Access Read As #f

Do While Loc(f) < LOF(f)
    Get f, , byt
    str1 = str1 & byt & vbNewLine
Loop

Close m

''' str1
''' different from the output when I use C# StreamReader to extract the data from the pdf file

End Sub
I guess there are many problems to be resolved if I really want to use VBA to count the pages of a pdf file.

First, I bet there is something to do with Binary.
The error "Input past end of file" seems to be caused by reading binary files and I think using Loc() could have helped solve it.
Second, I declare a variable for the binary data. I think it works with the binary data extracted from the pdf file.

But third, the output (string str1) is still different from what I get from a C# code (which works well to count the pages of a pdf file).

Anyway, I think I still need to be working hard on it since even I get the page count from the C# code. It cannot be used in Excel.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Input past end of file error: You are attempting to save a file format that is blocked by file block setting zatlas1 Office 8 04-28-2012 02:37 PM
Error: Input past end of file Error File in Word gleckie Word 2 02-02-2012 07:51 AM
Error: Input past end of file File Permission Error Pianoman 74 Word 3 01-26-2012 03:56 PM
File Conversion Error azii Word 0 01-04-2012 04:34 AM
Runtime error 5487 - Word cannot complete the save to to file permission error franferns Word 0 11-25-2009 05:35 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft