Enabling right click copy for ipython plots? - matplotlib

Is there a way to enable matplotlib/ipython so I can right click my plots (in Chrome) and copy then paste elsewhere such as MS Word etc?
I know I can code and save to image etc, but often when I am playing around investigating data it would be very useful to just copy / paste into a document for safekeeping and reports.
EDIT: Problem seems to be using MS Word (2010) and any dynamic image from any Browser (IE/Chrome), If I use other progs like Write it works okay. I found some advice to change the "Pasting from other programs" option in Word settings but it has no effect.
Also another article says the problem is based on the contents of the "HTML Format" format stored in the clipboard.
Guess I need to post this question elsewhere seems to be an MS Word issue!

If you control-shift right click, it'll return to the standard Chrome context menu instead of the iPython one.

EDIT: the below answer doesn't always work anymore (something changed I think), but there is another stack overflow question here with an answer that is working, namely using Ctrl+Alt+V to do a paste-special:
Jupyter Notebook: How to copy paste image into MS word?
A straight Ctrl+V will generally fail in MS Office for this purpose, but there is the "paste image" option which is what is working for me.

If you're using ipython notebook (which I guess you must be, since you're mentioning using Chrome), you can just right-click on your graph and choose Copy Image then paste into whatever software

Drag and drop worked for me using Chrome and MS Word on macOS.

Related

pdf table to excel in Automation anywhere

I am trying to get PDF tables in excel for further processing in Automation anywhere.I tried it like converting PDF to text and then to excel but it not working as required.
Please suggest if anyone did this.
Thanks all who replied and tried to help.
But, i got the solution as there is bot already for this in botstore of AA and we can use it.
We can use this metabot and logic to perform action.
PFB link for the same:
https://botstore.automationanywhere.com/bot/pdf-to-excel/
I think you can use OCR inbuild tool or PDF read tools and take those data items into the variables. And then try to use keystrokes (or other) to add those variables as text in textfile. As well as add those items to the excel sheet. try it.

VBA: set txt to be printed in Portrait mode

this time I'm fighting against a .txt file which doesn't want to be (programmatically) set to be printed in Portrait-mode instead of Landscape-mode (which is the default apparently).
Thing is I know how to do that with application like Word or Excel, but sadly enough I'm working on a device that has no Office at all.
I'm not providing any code at all since my problem is pretty straightforward, and I think I need a simple command in order to solve it. What I basically (programmatically) do in my subroutine is:
Open the file as #1 (I know this appears so '80, but I don't want to modify an up-and-running system, potentially having errors show up)
Write text to the file
Close #1
Save the file
Call text editor shell to show the file to the user
How can I then automatically set the print format to Portrait?
P.s.= I do not have the possibility to insert a userform or an object to print the txt file in "special ways", the user has to print the file from txt editor itself (wordpad just in case)
First to state the obvious: there are no print settings stored in text files (or indeed anything else except for the text). Print settings would be controlled within whatever you are using to print - in this case Notepad or Wordpad.
There are only very limited command line switches for Notepad and Wordpad, which unfortunately don't include page setup. In theory you may be able to automate setting portrait using SendKeys (see here and here) but if it is possible at all it's likely to be difficult and unreliable (focus and timing are two issues).
I can't see a good way round this within the parameters of your question. Adding an object within your application would probably have been the best solution. You might try looking for an alternative text editor you could install that is easier to automate. The only other alternative might be to set defaults within the printer drivers and hope that those stick when the user opens Notepad.

Macro fails in Word 2013

I have a Word macro that has been working fine for ages. I have recently upgraded to Word 2013 and the behavior has changed.
It occurs on the following line:
Doc.SaveAs Path + "Manual\" + TitleString + ".htm", wdFormatFilteredHTML
which builds a valid file path and name and saves the current document as an HTML page.
Under Word 2013, the macro opens a file save dialog box with no filename and with the default file extension (.docx) instead of (.htm), as if the filtered HTML mode was no more available.
I have tried with named arguments, and also with the new SaveAs2 method, but saw no change.
How can I solve this ?
I fond this comment on the DataZX.CN forum:"I Had the same problem. I'm running a windows 8/64bits on an ACER laptop. SOLUTION : remove the Add-in "Icloud Acer ...".
I happen to use Acer desktop, and there was indeed this Icloud add-in pre-installed in Word. After disabling it, the macro works !!!!!!!!!!!!!!!
Thanks StackOverflow for pointing me in the right direction as always...
and thanks Yves for spreading the info...
I removed Acer cloud plugin from Word and excel just to be on safe side.
Blame foolish manufacturers like Acer for another bundled piece of crap software that causes more harm than good.
Quoted from MSDN forum post...
http://social.msdn.microsoft.com/Forums/office/en-US/59c0da80-a7e6-4026-855c-f6b9fbf9c386/word-2013-vba-documentsaveas-dialog-appears-even-applicationclassdisplayalerts-?forum=worddev
...From all you tell me, my feeling is that there may be another third-party application (or a virus) mixing in - that the display of SaveAs is not coming from your application.
This is difficult for you to test, since whatever it is is probably loading with Word...

Word Automation Service breaks links in table of contents

I have written a code which utilizes Word Automation Service in order to convert the .DOCX file to the .PDF. I have noticed that in case the Word document contains a table of contents, its links are removed in the PDF. This is very bad for my business case.
On the other hand, manually opening MS Word and saving the same document as PDF preserves the links in the table of contents. This is the behavior I am looking for, but I want to keep my code independent form having MS Office Word installed on the machine running my code.
Has anyone had the similar issue and was anybody able to resolve it?
In my case, i found out that this is something related to Job Settings property. Try to comment or remove this line of code if you have one:
jobSettings.UpdateFields = true;

How to Pretty print VBA code?

How do you copy VBA code into a Word document and retain the VBA editor color scheme?
You can use Notepad++ to accomplish this in three ways. Just so you know, Notepad++ is a more advanced version of Notepad, which supports syntax highlighting of different code files "out of the box" - Visual Basic included!
Download & install it, fire it up, and load up your VBA code. You should automatically see it beautifully coloured (if not, because the file extension is something other than .vb, go to Language -> VB or Language -> V -> VB).
If you need to change any of the colours, you can easily do so - just go to Settings -> Styler Configurator. From that menu, you can change the various highlighting and font options, to suit your needs - although the default usually suffices for most.
Then, go to Plugins -> NppExport. From there, you have three options you can consider:
Directly print from Notepad++
Copy all formats to clipboard
Export to RTF
Export to HTML
The first is self explanatory. The second one - "Copy all formats to clipboard" - will copy the entire file with the highlighted syntax to the clipboard. Once you click it, then open Microsoft Word or your other favourite document editor, and just hit paste! You should see the beautifully syntax-highlighted code. If something goes wrong, then you can try one of the other options (export to RTF/HTML), although I've never had a problem with the clipboard method.
There are two programs on cnet downloads, which are free to try. In case you did not try them, here are the links:
VB-VBA Code Formatter & Printer 2.2
VBAcodePrint 6.13.110
Smart Indenter could be what you're looking for? You'd load the result into Notepad++, set language to VB and save as .rtf/.doc (or print to file, can't remember off the top of my head).
For a more modern approach, Sublime Text users can install ExportHTML from Package Control. This has the added benefit of being able to include the line numbers, and changing the code coloration.
HTML files can be opened directly within Word.
Highlight supports a wide range of Operating Systems and 150+ languages including Visual Basic, although I'm not sure about VBA.
I would recommend this one: planetB
It works well with Internet Explorer (didn't work wit Firefox for me, not sure abt Chrome).
Plus it's online, so no need to install anything (the case of Company/University PC's)
Regards
Wheeliam
The following works with Visual Studio Code:
Start VS Code.
New file.
Copy & Paste the VBA code into the VS Code window.
In the lower right-hand corner, click on "Plain Text" and select "Visual Basic" instead. Note that the code is now syntax-highlighted.
Copy & Paste the formatted code into Word.