locked
Export data from already opened temporary workbook via powershell RRS feed

  • Question

  • Hello,

    Is there any way to copy data (export a sheet) from already opened but unsaved workbook (temporary file) via powershell? 

    That is, how to activate the temporary file after $xl=[Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application"), if location is not known?

    Thanks,

    M

    Wednesday, July 3, 2019 4:42 PM

All replies

  • Hello,

    Is there any way to copy data (export a sheet) from already opened but unsaved workbook (temporary file) via powershell? 

    That is, how to activate the temporary file after $xl=[Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application"), if location is not known?

    Thanks,

    M

    • Merged by jrv Wednesday, July 3, 2019 5:08 PM DUPLICATE
    Wednesday, July 3, 2019 4:39 PM
  • All opened files are I n "Documents"

    $xl.Workbooks

    You will have to discover which document is the one of interest.


    \_(ツ)_/


    • Edited by jrv Thursday, July 4, 2019 6:16 AM
    Wednesday, July 3, 2019 5:05 PM
  • Hi,

    Thanks for your question.

    Sorry. I don't think you can do that.

    About powershell excel module, you can use it to import/export Excel spreadsheets, without Excel.

    https://www.powershellgallery.com/packages/ImportExcel/5.2.0

    Best regards,

    Lee


    Just do it.

    Thursday, July 4, 2019 6:11 AM
  • Of course you can do that.  The code can do that very easily.  Try it.

    Open Excel and create a new workbook.   Run the PowerShell code.  You can do anything you want with the new, unsaved (temporary), workbook.

    The error in the question is that it assumes you need to access a file. You don't.  Just access the Workbook from the excel Workbooks object.

    The Excel modules cannot do what has been asked.


    \_(ツ)_/


    • Edited by jrv Thursday, July 4, 2019 6:16 AM
    Thursday, July 4, 2019 6:14 AM
  • Also I posted the wrong object.  the above should be:

    $xl.Workbooks

    Not $xl.Documents.


    \_(ツ)_/

    Thursday, July 4, 2019 6:17 AM