ruxer has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: coding for excel in perl
by davies (Monsignor) on Dec 27, 2009 at 17:27 UTC | |
But you may need to get rid of the braces - I haven't tested this. Regards, John Davies | [reply] [d/l] |
by ruxer (Acolyte) on Dec 27, 2009 at 17:52 UTC | |
david | [reply] |
|
Re: coding for excel in perl
by Corion (Patriarch) on Dec 27, 2009 at 15:22 UTC | |
Basically, you use Win32::OLE to make the same calls from Perl that you would do from VBA. The Win32::OLE documentation shows how to translate the calls. | [reply] |
|
Re: coding for excel in perl
by CountZero (Bishop) on Dec 27, 2009 at 15:08 UTC | |
It is customary that you show some relevant example code you have written yourself. In this case --for instance-- a small Perl-script which opens an Excel-file, selects and put in the copy buffer some cells and then needs to be completed with the code to release the copy-selection. You are much more likely to receive favourable answers if you show that you have at least tried but failed, rather than having failed for not having tried at all. It is not a shame to fail, but it is a sin in our Monastery not to try. CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James | [reply] |
by ruxer (Acolyte) on Dec 27, 2009 at 15:53 UTC | |
Thank you CountZero! The following --portion of script-- is copying from one sheet and pasting to another to prepare for print. Everything works beautifully except for the line "$Excel->Application->CutCopyMode = False;". I have tried writing the line several different ways and I have searched google and multiple other sights for ideas. Opening of script is: The following is the portion of script containing the line in question. Thank you in advance for any help you can give. david | [reply] [d/l] [select] |
|
Re: coding for excel in perl
by ruxer (Acolyte) on Dec 27, 2009 at 18:09 UTC | |
Given: The VBA code "Application.CutCopyMode = False" in perl is: Thanks to all who responded, especially davies. ruxer | [reply] [d/l] [select] |
|
Re: coding for excel in perl
by jeffreyray (Sexton) on Dec 28, 2009 at 15:52 UTC | |
If you plan to use Win32::OLE to interact with Microsoft applications often - I have found ActiveState's VBScriptConverter which ships with their PDK Productivity Tools to be very helpful. This program will convert VB Macros directly to Perl code. Another useful tip: After recording a Macro in Excel - press Alt+F11. This will open up Visual Basic where you will be able to view and edit the VBScript generated when you recorded the Macro. You can then convert this to perl yourself using the rules in the Win32::OLE documentation - or paste it into the VBScriptConverter and let it do the work. From within Visual Basic - you can also press F2 (or select View->Object Browser) to bring up the object browser. Here you can view the different attributes and methods of the different objects you can interact with. I find that when you are unsure of how to do something, this is the easiest way to figure it out is to record the Macro and then look at the VBScript that was generated. This is usually much easier and quicker than piling through documentation. | [reply] |