Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-09-2014, 04:38 AM
XmisterIS XmisterIS is offline How to read binary data from currently open file? Windows 7 64bit How to read binary data from currently open file? Office 2007
Novice
How to read binary data from currently open file?
 
Join Date: Sep 2013
Posts: 12
XmisterIS is on a distinguished road
Default How to read binary data from currently open file?

*** SOLVED ***



Here's the problem:

I have a web-based facility for uploading word documents. This facility parses the xml data of the document and extracts the data that is required.

I am now writing a macro that will allow the user to upload the document directly to the server via cURL at the click of a button on the Quick Access toolbar.

I have adapted the code from here (http://stackoverflow.com/questions/8...ry-file-to-var) to read in the document's binary data, as follows:

Code:
Public Sub Sandbox()
    filename = ActiveDocument.Path & "\" & ActiveDocument.name
    
    Dim f As Integer
    f = FreeFile()
    
    Open filename For Binary Access Read As #f
        bin2var = Space(FileLen(filename))
        Get #f, , bin2var
    Close #f
End Sub
The trouble is, of course, that I get a "permission denied" error because the file that I want to read is the currently open file!

It has been suggested that I write a macro which extracts the data required and then uploads it to the server, but from my point of view that is absurd - I already have a perfectly good PHP script to do the job, I don't want to re-invent the wheel.

How can I read the raw binary data of the currently open file?

*** SOLVED ***
No worries - sorted it myself.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't open objects in read-only Word 2007 document Calab Word 6 04-07-2014 05:02 AM
How to read binary data from currently open file? HELP: Binary page numbering mechwurm Word 3 03-27-2014 10:57 AM
How to read binary data from currently open file? excel cannot open the file .xlsx because the file format or file extension is not val teddysika Excel 1 11-22-2012 06:06 AM
Word documents suddenly and randomly open read only Jennifer Murphy Word 0 09-03-2011 10:13 PM
How to read binary data from currently open file? Open an outlook 2003 pst data-file from inside outlook 2010 pinholt Outlook 2 11-10-2010 07:16 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 05:14 AM.


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