I am developing an application that opens and reads an XML document previously built into a PowerPoint presentation, or a Word document. To read this object ( xmlFile as Object ), I have to do:
xmlFile.OLEFormat.DoVerb 1
This opens the package object, and I have another routine that receives an open instance of Notepad.exe and reads its contents into the ADODB stream.
An example of this procedure is available in Google Docs:
XML_Test.pptm .
During this process, there are a few seconds of a window where Notepad.exe receives focus, and an inadvertent key press can cause unwanted results or an error while reading XML data.
I am looking for one of two things:
- Or a method to prevent unintentional user input (via keyboard / mouse / etc.) during this operation. What is preferable is that it does not control the user machine, such as the
MouseKeyboardTest routine, below. Or, - The best way to extract XML data into a string variable.
For # 1: this is the function I found that I use. I am wary of such control over the user system. ## Are there any other methods that I could use? ##
Private Declare Function BlockInput Lib "USER32.dll" (ByVal fBlockIt As Long) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub MouseKeyboardTest() 'both keyboard and mouse blocked BlockInput True ' Turns off Keyboard and Mouse ' Routine goes here Sleep 5000 ' Optional coding BlockInput False ' Turns on Keyboard and Mouse End Sub
For # 2: Some background, but the problem is the inability to reliably retrieve the embedded object using any method other than DoVerb 1 . Since I am dealing with an unsaved document in an application (Notepad) that is immune to my VBA skill, this is apparently the only way to do this. Full text about this here:
Extract an OLEObject (XML document) from PowerPoint VBA
vba powerpoint-vba ole adodb
David zemens
source share