ole - VBA to Prevent Keyboard Input While a Package Object (XML) is Read into ADODB Stream? -


i developing application opens , reads xml document embedded in powerpoint presentation, or word document. in order read object (xmlfile object) have do:

xmlfile.oleformat.doverb 1

this opens package object, , have subroutine gets open instance of notepad.exe, , reads contents in adodb stream.

an example of procedure available on google docs:

xml_test.pptm.

during process there few seconds window notepad.exe gains focus, , inadvertent keystroke may cause undesired results or error reading xml data.

i looking 1 of 2 things:

  1. either method prevent user inadvertently inputting (via keyboard/mouse/etc) while operation being performed. preferably not take control of user's machine mousekeyboardtest subroutine, below. or,
  2. a better method of extracting xml data string variable.

for #1: function found, leery of using. wary of taking sort of control of users system. ##are there other methods might use?##

private declare function blockinput lib "user32.dll" (byval fblockit long) long private declare sub sleep lib "kernel32" (byval dwmilliseconds long)  sub mousekeyboardtest() 'both keyboard , mouse blocked      blockinput true ' turns off keyboard , mouse '   routine goes here     sleep 5000 ' optional coding     blockinput false ' turns on keyboard , mouse  end sub 

for #2: background, issue seems inability extract embedded object reliably using method other doverb 1. since dealing unsaved document in application (notepad) immune vba skillz, seems way this. full background on that, here:

extracting oleobject (xml document) powerpoint vba

my understanding have control on how xml file gets embedded powerpoint presentation in first place. here not quite understand why chose keep data need contents of embedded object.

to sure, task of getting contents not piece of cake. actually, long there no (simple or moderately difficult) way call queryinterface , use ipersist* interfaces vba, there 1 way contents of embedded object. way involves following steps:

  1. activate embedded object. used oleformat.doverb 1 that. better way call oleformat.activate, irrelevant particular problem.
  2. use embedded object's programming model perform useful operations getting contents, saving or whatever exposed. notepad.exe exposes no such programming model, , resorted winapi best choice available.

unfortunately, current approach has @ least 2 flaws:

  1. the 1 identified in question (activation of notepad.exe leading possibility of user's interference).
  2. if user has default program opening .txt files other notepad.exe, approach doomed.

if have control on how embedded object created better approach store xml data in property of shape object. use shape.alternativetext (very straightforward use; shouldn't used if export .pptm html or have different scenario alternativetext matters) or shape.tags (this 1 semantically correct task) that.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -