Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After a lot (a LOT) of searching, I had written this off and was moving on to one of several "Plan B" solutions, when I stumbled on a possible solution.</p> <p>I know that <code>DoVerbs 1</code> activates the embedded package file (.txt, .xml, etc) but I did not have any control over the new instance of Notepad, from which I need to read the XML contained therein.</p> <p>Instead of copying and trying to paste the object (which fails manually and programmatically)</p> <pre><code>'Save this out to a drive so it can be accessed by a COM Object: metaDoc.Copy CreateObject("Shell.Application").Namespace(ActivePresentation.Path).self.InvokeVerb "Paste" </code></pre> <p>I was able to use a slightly modified version of the solution posted here:</p> <p><a href="http://www.excelforum.com/excel-programming-vba-macros/729730-access-another-unsaved-excel-instance-and-unsaved-notepad-text.html" rel="nofollow">http://www.excelforum.com/excel-programming-vba-macros/729730-access-another-unsaved-excel-instance-and-unsaved-notepad-text.html</a></p> <p>to read the open, unsaved instance of Notepad as a string, which I then write to a new file. This is called from the <code>NotepadFunctions.ReadNotepad()</code> function documented in the above mentioned link.</p> <pre><code>Sub ExtractLocalXMLFile(xlsFile As Object) 'Extracts an embedded package object (TXT file, for example) ' reads string contents in from Notepad instance and ' prints a new file with string contents from embed file. Dim embedSlide As slide Dim DataObj As New MSForms.DataObject 'This is the container for clipboard contents/object Dim fullXMLString As String 'This is the captured string from clipboard. Dim t As Long 'Timer variable MsgBox "Navigating to the hidden slide because objects can only be activated when " &amp; _ "the slide is active." Set embedSlide = ActivePresentation.Slides("Hidden") ActivePresentation.Windows(1).View.GotoSlide embedSlide.SlideIndex 'Make sure no other copies of this exist in temp dir: On Error Resume Next Kill UserName &amp; "\AppData\Local\Temp\" &amp; _ MetaDataXML_FilePath 'replace an xls extension with txt On Error GoTo 0 xlsFile.OLEFormat.DoVerb 1 '1 opens XML package object -- ' for xls/xlsm files use Verb 2 to Open. ' in which case I can maybe control Notepad.exe t = Timer + 1 Do While Timer &lt; t 'Wait... while the file is opening Wend 'Retrieve the contents of the embedded file fullXMLString = Notepad_Functions.ReadNotepad(Notepad_Functions.FindNotepad("Chart Meta XML")) 'This function closes Notepad (would make it a subroutine, instead. 'CloseAPP_B "NOTEPAD.EXE" '&lt;--- this function is NOT documented in my example on StackOverflow 'Create a new text file WriteOutTextFile fullXMLString, MetaDataXML_FilePath 'Get rid of the embedded file xlsFile.Delete End Sub Sub WriteOutTextFile(fileString As String, filePath As String) 'Creates a txt file at filePath 'inserting contents (filestring) from the temp package/XML object Dim oFile As Object Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") Set oFile = fso.CreateTextFile(filePath) oFile.WriteLine (fileString) oFile.Close End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload