RE: Win32::OLE Module - Excel chart Generation Problem
While I don't have your exact setup, this script works fine in perl 5.8 (32-bit), Excel 2003 (32-bit) on Win Server 2003 (32-bit).. Yes, it's a dated config.. But it's running fine for now. As well, I ran this on Win7 (x64), Perl 5.8 (32-bit), Excel 2010 (32-bit). it worked fine again. (Which seems to point to the version of office not being an issue -- 2003 - 2010 should work fine if 2003 and 2010 do. I'd suspect that the Office you have might be 32-bit and you are trying to use Perl64 which may have issues calling a 32-bit object (64-bit calls to a 32-bit COM object) although I can't guarantee that .. I just know that I run into this particualr problem in VBScript unless I use the 32-bit VBScript engine in %SYSTEMROOT%\syswow64\cscript.exe when invoking 32-bit COM objects (like my office apps). If the script you provided is the exact script you used to generate the error, it seems as though it's complaining about this line... Which somewhat points to charting being a suspect for a 32-bit COM object. Line 20 = $Chart-{ChartType} = xlAreaStacked; But again, I've ignored the possibility of Perl having an issue as I don't have v5.16 or perl64 handy to test in your particular config, nor did you tell us if the Office you have is 64 or 32-bit (which would add to the troubleshooting of this issue). FYI and HTH Steven From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of ketan patel Sent: Tuesday, April 09, 2013 2:21 PM To: perl-win32-users@listserv.ActiveState.com Subject: Win32::OLE Module - Excel chart Generation Problem Hello All, I am running following simple script on perl64 to generate chart on excel but I am getting following errors without generating any chart. It opens excel sheet, write data into sheet but no chart. Win32::OLE(0.1709) error 0x80020003: Member not found in PROPERTYPUT ChartType at C:\path\test.pl line 20. Here is my system spec PERL version : Perl 64 v5.16.3 WIN32 OLE : 0.1709 Excel Version : Excel 2007 SP3 Can anyone please give me some input on how I can remove this error and generate chart ? Thank you, ==Script === use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; my $Excel = Win32::OLE-new(Excel.Application); $Excel-{Visible} = 1; $Win32::OLE::Warn = 3; my $Book = $Excel-Workbooks-Add; my $Sheet = $Book-Worksheets(1); my $Range = $Sheet-Range(A2:C7); $Range-{Value} = [['Delivered', 'En route', 'To be shipped'], [504, 102, 86], [670, 150, 174], [891, 261, 201], [1274, 471, 321], [1563, 536, 241]]; my $Chart = $Excel-Charts-Add; $Chart-{ChartType} = xlAreaStacked; $Chart-SetSourceData({Source = $Range, PlotBy = xlColumns}); $Chart-{HasTitle} = 1; ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE events callback not executed
I'm willing to pay anyone that can make this work. If anyone is interested, send me a personal email. Thanks On Sun, Mar 25, 2012 at 12:52 AM, haratron harat...@gmail.com wrote: I'm so desperate about this. Could anyone at least point in the right direction? Is WithEvents broken? There's the pyTTS module in Python that succeeds in firing the events. Yet I can't figure out how to port it. On Mon, Mar 19, 2012 at 9:46 PM, Howard Tanner tan...@optonline.net wrote: Thanks anyway Jan. -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Jan Dubois Sent: Monday, March 19, 2012 3:45 PM To: 'Howard Tanner'; 'haratron' Cc: perl-win32-users@listserv.activestate.com Subject: RE: Win32::OLE events callback not executed On Mon, 19 Mar 2012, Howard Tanner wrote: I couldn't get any events to be fired either. Perhaps Jan can weigh in since he seems to be around today. Sorry, I don't know _why_ it isn't working, but I've seen others run into the same problem with SAPI. Unfortunately I don't have time to play with SAPI stuff myself, so I won't be able to help much. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE events callback not executed
I'm so desperate about this. Could anyone at least point in the right direction? Is WithEvents broken? There's the pyTTS module in Python that succeeds in firing the events. Yet I can't figure out how to port it. On Mon, Mar 19, 2012 at 9:46 PM, Howard Tanner tan...@optonline.net wrote: Thanks anyway Jan. -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Jan Dubois Sent: Monday, March 19, 2012 3:45 PM To: 'Howard Tanner'; 'haratron' Cc: perl-win32-users@listserv.activestate.com Subject: RE: Win32::OLE events callback not executed On Mon, 19 Mar 2012, Howard Tanner wrote: I couldn't get any events to be fired either. Perhaps Jan can weigh in since he seems to be around today. Sorry, I don't know _why_ it isn't working, but I've seen others run into the same problem with SAPI. Unfortunately I don't have time to play with SAPI stuff myself, so I won't be able to help much. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE events callback not executed
From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of haratron Sent: Monday, March 19, 2012 11:21 AM To: perl-win32-users@listserv.ActiveState.com Subject: Win32::OLE events callback not executed Hello, I want to implement karaoke functionality on my TTS (text to speech) editor. Meaning that I want to highlight words the moment they are spoken by the TTS system. I read that I need to watch for the onWord event. I have the same problem with this person: http://www.mail-archive.com/perl-win32-users@listserv.activestate.com/msg275 30.html The callback never gets executed. How can I fix this? Thank you, haratron ___ Here's the dox from M$ on the Word event: http://msdn.microsoft.com/en-us/library/ms723593(v=vs.85).aspx It includes a VB example that does exactly what you want. Perhaps someone here better at Perl than me can help you translate it. I don't know where Mr. James Brown got his ordinal from, but I suspect the number 32, if that's correct at all, will be O/S version dependent, since different versions of Windows have slightly different versions of SAPI. Perhaps there's a better way in Perl to trap the Word event than using the ordinal. And note that the event is Word, not onWord. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE events callback not executed
I couldn't get any events to be fired either. Perhaps Jan can weigh in since he seems to be around today. Here's my test code: use strict; use Win32::OLE qw(EVENTS); my $vox = Win32::OLE-new ('SAPI.SpVoice') || die Unable to create SAPI object\n; sub Event { my ($Obj, $Event, @Args) = @_; print Event: $Event\n; } Win32::OLE-WithEvents ($vox, \Event); $vox-{'EventInterests'} = 32; #Fire only new word events my $text = This is the Microsoft Speech Library.; $vox-Speak ($text, 1); #Read text asynchronously Win32::OLE-MessageLoop (); -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of haratron Sent: Monday, March 19, 2012 1:54 PM To: Howard Tanner Cc: perl-win32-users@listserv.activestate.com Subject: Re: Win32::OLE events callback not executed Thanks for the answer. I've also found these links that can help maybe: http://code.activestate.com/lists/activeperl/13161/ -- tried it, callback still doesn't get executed http://www.perlmonks.org/?node_id=429272 -- tried it, doesn't work I'm finding it difficult to translate that VB code to Perl. If anyone can help, much appreciated. On Mon, Mar 19, 2012 at 7:01 PM, Howard Tanner tan...@optonline.net wrote: From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of haratron Sent: Monday, March 19, 2012 11:21 AM To: perl-win32-users@listserv.ActiveState.com Subject: Win32::OLE events callback not executed Hello, I want to implement karaoke functionality on my TTS (text to speech) editor. Meaning that I want to highlight words the moment they are spoken by the TTS system. I read that I need to watch for the onWord event. I have the same problem with this person: http://www.mail-archive.com/perl-win32-users@listserv.activestate.com/ msg275 30.html The callback never gets executed. How can I fix this? Thank you, haratron ___ Here's the dox from M$ on the Word event: http://msdn.microsoft.com/en-us/library/ms723593(v=vs.85).aspx It includes a VB example that does exactly what you want. Perhaps someone here better at Perl than me can help you translate it. I don't know where Mr. James Brown got his ordinal from, but I suspect the number 32, if that's correct at all, will be O/S version dependent, since different versions of Windows have slightly different versions of SAPI. Perhaps there's a better way in Perl to trap the Word event than using the ordinal. And note that the event is Word, not onWord. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE events callback not executed
On Mon, 19 Mar 2012, Howard Tanner wrote: I couldn't get any events to be fired either. Perhaps Jan can weigh in since he seems to be around today. Sorry, I don't know _why_ it isn't working, but I've seen others run into the same problem with SAPI. Unfortunately I don't have time to play with SAPI stuff myself, so I won't be able to help much. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE
Try this: http://stackoverflow.com/questions/837754/call-routine-in-access-module-from-net On Wed, Jun 29, 2011 at 10:19 AM, John Harrington bearti...@gmail.com wrote: Hi Leo, Thanks for this. I tried this script on one of the machines that wasn't working yesterday and received only this error: Last OLE32 error: Win32::OLE(0.1709) error 0x800a9d9f in METHOD/PROPERTYGET Run Any suggestions? So far I've tried automation on four separate machines: All with Access 2007 12.0.6535.5005 SP2 MSO 12.0.6554.5001 OS bits Perl version Works? XP 32 5.10.1 yes XP 32 5.12.4 no W7 64 5.12.4 yes W7? 64? 5.10.1 no I believe OS, bits, Perl version, and Access version can be ruled out as the explanation. Thank you again, John On Tue, Jun 28, 2011 at 5:35 PM, Leo Susanto leosusa...@gmail.com wrote: Thank, so Access 2007 is installed in all of the machine Could you please run this and see if there is any error? use strict; use warnings; use Win32::OLE; my $oAccess; eval {$oAccess = Win32::OLE-GetActiveObject(Access.Application)}; if ($@) { die Access.Application is not installed\n; } unless (defined $oAccess) { unless ($oAccess = Win32::OLE-new(Access.Application, sub {$_[0]-Quit;})) { die Can not start Access.Application\n; } } $oAccess-OpenCurrentDatabase(C:\\vpdb\\depot\\VProject\\Database\\xdb.accdb); print Last OLE32 error: . Win32::OLE-LastError() if (Win32::OLE-LastError()); $oAccess-Run(AutomationTest); print Last OLE32 error: . Win32::OLE-LastError() if (Win32::OLE-LastError()); On Tue, Jun 28, 2011 at 4:36 PM, John Harrington bearti...@gmail.com wrote: I have a very simple script using Win32::OLE that works perfectly on my machine but not on other people's machines and I can't figure out why. The script is as follows: use strict; use warnings; use Win32::OLE; my $oAccess; $oAccess = Win32::OLE-new('Access.Application') or die Unable to start Access; $oAccess-OpenCurrentDatabase(C:\\vpdb\\depot\\VProject\\Database\\xdb.accdb); $oAccess-Run(AutomationTest) When I run it on my machine, it successfully runs a Public Function called AutomationTest in my database. This function writes two files to the cwd, a text file and a simple Excel spreadsheet. When I run this script on other people's machines, the script executes (same OS, same version of ActiveState Perl (5.10.1), same database, same permissions) but the files are not written, which suggests the automation is not working. No errors are generated. The script runs, but there are no files produced. Again, it works on my machine, not on theirs, with apparently the very same conditions. I even tried sharing my Perl folder so another user could be assured he was running the same version of the module and Perl. I am at my wit's end. Any help would be appreciated. Can you think of any reason such a simple application of the Win32::OLE module would work on one machine and not on another? Thanks, John ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE
Hi Leo, Yes, it turns out the security setting is the issue. On machines where this didn't work, the security settings were different than on the machines where it did work. Thank you very much for your help with this puzzling issue. It is very much appreciated. For any other users who may find this thread on Google, it was necessary to modify the Access security settings to get automation to run. To do that in Access 2007: 1. Open Access. 2. Click the Office button (the circle in the extreme upper right). 3. Select the Access Options... button. 4. On the Access Options dialog, click Trust Center. 5. Click Trust Center Settings 6. On the Trust Center dialog, click Macro Settings. 7. Select Enable all macros (last option). Best regards, John On Wed, Jun 29, 2011 at 11:06 AM, Leo Susanto leosusa...@gmail.com wrote: Try this: http://stackoverflow.com/questions/837754/call-routine-in-access-module-from-net On Wed, Jun 29, 2011 at 10:19 AM, John Harrington bearti...@gmail.com wrote: Hi Leo, Thanks for this. I tried this script on one of the machines that wasn't working yesterday and received only this error: Last OLE32 error: Win32::OLE(0.1709) error 0x800a9d9f in METHOD/PROPERTYGET Run Any suggestions? So far I've tried automation on four separate machines: All with Access 2007 12.0.6535.5005 SP2 MSO 12.0.6554.5001 OS bits Perl version Works? XP 32 5.10.1 yes XP 32 5.12.4 no W7 64 5.12.4 yes W7? 64?5.10.1no I believe OS, bits, Perl version, and Access version can be ruled out as the explanation. Thank you again, John On Tue, Jun 28, 2011 at 5:35 PM, Leo Susanto leosusa...@gmail.com wrote: Thank, so Access 2007 is installed in all of the machine Could you please run this and see if there is any error? use strict; use warnings; use Win32::OLE; my $oAccess; eval {$oAccess = Win32::OLE-GetActiveObject(Access.Application)}; if ($@) { die Access.Application is not installed\n; } unless (defined $oAccess) { unless ($oAccess = Win32::OLE-new(Access.Application, sub {$_[0]-Quit;})) { die Can not start Access.Application\n; } } $oAccess-OpenCurrentDatabase(C:\\vpdb\\depot\\VProject\\Database\\xdb.accdb); print Last OLE32 error: . Win32::OLE-LastError() if (Win32::OLE-LastError()); $oAccess-Run(AutomationTest); print Last OLE32 error: . Win32::OLE-LastError() if (Win32::OLE-LastError()); On Tue, Jun 28, 2011 at 4:36 PM, John Harrington bearti...@gmail.com wrote: I have a very simple script using Win32::OLE that works perfectly on my machine but not on other people's machines and I can't figure out why. The script is as follows: use strict; use warnings; use Win32::OLE; my $oAccess; $oAccess = Win32::OLE-new('Access.Application') or die Unable to start Access; $oAccess-OpenCurrentDatabase(C:\\vpdb\\depot\\VProject\\Database\\xdb.accdb); $oAccess-Run(AutomationTest) When I run it on my machine, it successfully runs a Public Function called AutomationTest in my database. This function writes two files to the cwd, a text file and a simple Excel spreadsheet. When I run this script on other people's machines, the script executes (same OS, same version of ActiveState Perl (5.10.1), same database, same permissions) but the files are not written, which suggests the automation is not working. No errors are generated. The script runs, but there are no files produced. Again, it works on my machine, not on theirs, with apparently the very same conditions. I even tried sharing my Perl folder so another user could be assured he was running the same version of the module and Perl. I am at my wit's end. Any help would be appreciated. Can you think of any reason such a simple application of the Win32::OLE module would work on one machine and not on another? Thanks, John ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE
Thank, so Access 2007 is installed in all of the machine Could you please run this and see if there is any error? use strict; use warnings; use Win32::OLE; my $oAccess; eval {$oAccess = Win32::OLE-GetActiveObject(Access.Application)}; if ($@) { die Access.Application is not installed\n; } unless (defined $oAccess) { unless ($oAccess = Win32::OLE-new(Access.Application, sub {$_[0]-Quit;})) { die Can not start Access.Application\n; } } $oAccess-OpenCurrentDatabase(C:\\vpdb\\depot\\VProject\\Database\\xdb.accdb); print Last OLE32 error: . Win32::OLE-LastError() if (Win32::OLE-LastError()); $oAccess-Run(AutomationTest); print Last OLE32 error: . Win32::OLE-LastError() if (Win32::OLE-LastError()); On Tue, Jun 28, 2011 at 4:36 PM, John Harrington bearti...@gmail.com wrote: I have a very simple script using Win32::OLE that works perfectly on my machine but not on other people's machines and I can't figure out why. The script is as follows: use strict; use warnings; use Win32::OLE; my $oAccess; $oAccess = Win32::OLE-new('Access.Application') or die Unable to start Access; $oAccess-OpenCurrentDatabase(C:\\vpdb\\depot\\VProject\\Database\\xdb.accdb); $oAccess-Run(AutomationTest) When I run it on my machine, it successfully runs a Public Function called AutomationTest in my database. This function writes two files to the cwd, a text file and a simple Excel spreadsheet. When I run this script on other people's machines, the script executes (same OS, same version of ActiveState Perl (5.10.1), same database, same permissions) but the files are not written, which suggests the automation is not working. No errors are generated. The script runs, but there are no files produced. Again, it works on my machine, not on theirs, with apparently the very same conditions. I even tried sharing my Perl folder so another user could be assured he was running the same version of the module and Perl. I am at my wit's end. Any help would be appreciated. Can you think of any reason such a simple application of the Win32::OLE module would work on one machine and not on another? Thanks, John ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE on MS Word using Selection.Find.Execute
Peter Buck wrote: Does anyone have an example of a perl script acting on MS Word documents using Win32::OLE and Selection.Find.Execute? I have read the Win32 man page but its examples for Excel and Access don't help. I found a Powershell script that does what I want but can't translate. The parts I'm confused on are (1) setting the parameters used in the Selection.Find.Execute() invocation (particularly the boolean values, since perl doesn't do booleans) and the actual invocation of Selection.Find.Execute(). I did find an example using $search- Execute() but this doesn't appear to allow setting all the parameters that Selection.Find.Execute() does. Also, it operates on $doc- Content-Find while Selection.Find.Execute() operates on $doc-Selection (if I'm right). And I'm using Homekey(6) to take me to the top of the document, which is linked to Selection and doesn't seem to work in my $doc-Content-Find attempts. Any help or direction to documentation much appreciated. The primary documentation for OLE apps is the Visual Basic Reference. The OLE browser supplied with Activestate Perl is also very useful, I find. Other than that, googling for examples can be useful, followed by an amount of trial and error. The amount of trial and error needed will depend on how closely the results of your googling match what you are trying to do. Thanks - Toolsmith # ExpandAcronyms.ps1 # read acronym list, expand acronyms in target MS Word document # syntax: ExpandAcronyms wordDocument function make-change { $FindText = $args[0] $FullText = $args[1] $ReplaceText = $FullText ($FindText) $ReplaceAll = 1 $FindContinue = 1 $MatchCase = $True $MatchWholeWord = $True $MatchWildcards = $False $MatchSoundsLike = $False $MatchAllWordForms = $False $Forward = $True $Wrap = $FindContinue# don't want it wrapping, wish I knew what this meant $Format = $False $objWord.Selection.HomeKey(6) Null $result = $objSelection.Find.Execute($FindText,$MatchCase, $MatchWholeWord,$MatchWildcards,$MatchSoundsLike, $MatchAllWordForms,$Forward,$Wrap,$Format, $ReplaceText,$ReplaceAll) if ( $result -eq $true ) { $Findtext|$FullText } } if ( $args.count -lt 1 ) { cd $env:temp $strWordFile = [string](resolve-path(Read-Host Enter Path of Word file to be processed)) } else { $strWordFile = [string](resolve-path($args[0])) } $objWord = New-Object -ComObject word.application $objWord.Visible = $True $objDoc = $objWord.Documents.Open($strWordFile) $objSelection = $objWord.Selection $d = get-content d:/temp/acronyms.txt# read file of acronym | definition foreach ( $l in $d ) { ($acro, $def) = $l.split('|')# build array of acronym, definition make-change $acro $def } Finished $objWord.Selection.HomeKey(6) Null That looks like shell script rather than Perl (Powershell perhaps?). Your Perl code would have been more useful. HTH -- Brian Raven Please consider the environment before printing this e-mail. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE on MS Word using Selection.Find.Execute
Peter, OLE needs Variant values. Perl and the OLE modules will convert most of these on he fly for you, but sometimes I find I have a need to convert booleans explicitly. my $false = Win32::OLE::Variant-new(VT_VARIANT, 0); my $true = Win32::OLE::Variant-new(VT_VARIANT, 1); Mark On 9/12/2010 4:43 PM, Peter Buck wrote: Does anyone have an example of a perl script acting on MS Word documents using Win32::OLE and Selection.Find.Execute? I have read the Win32 man page but its examples for Excel and Access don't help. I found a Powershell script that does what I want but can't translate. The parts I'm confused on are (1) setting the parameters used in the Selection.Find.Execute() invocation (particularly the boolean values, since perl doesn't do booleans) and the actual invocation of Selection.Find.Execute(). I did find an example using $search- Execute() but this doesn't appear to allow setting all the parameters that Selection.Find.Execute() does. Also, it operates on $doc- Content-Find while Selection.Find.Execute() operates on $doc-Selection (if I'm right). And I'm using Homekey(6) to take me to the top of the document, which is linked to Selection and doesn't seem to work in my $doc-Content-Find attempts. Any help or direction to documentation much appreciated. Thanks - Toolsmith # ExpandAcronyms.ps1 # read acronym list, expand acronyms in target MS Word document # syntax: ExpandAcronyms wordDocument function make-change { $FindText = $args[0] $FullText = $args[1] $ReplaceText = $FullText ($FindText) $ReplaceAll = 1 $FindContinue = 1 $MatchCase = $True $MatchWholeWord = $True $MatchWildcards = $False $MatchSoundsLike = $False $MatchAllWordForms = $False $Forward = $True $Wrap = $FindContinue# don't want it wrapping, wish I knew what this meant $Format = $False $objWord.Selection.HomeKey(6) Null $result = $objSelection.Find.Execute($FindText,$MatchCase, $MatchWholeWord,$MatchWildcards,$MatchSoundsLike, $MatchAllWordForms,$Forward,$Wrap,$Format, $ReplaceText,$ReplaceAll) if ( $result -eq $true ) { $Findtext|$FullText } } if ( $args.count -lt 1 ) { cd $env:temp $strWordFile = [string](resolve-path(Read-Host Enter Path of Word file to be processed)) } else { $strWordFile = [string](resolve-path($args[0])) } $objWord = New-Object -ComObject word.application $objWord.Visible = $True $objDoc = $objWord.Documents.Open($strWordFile) $objSelection = $objWord.Selection $d = get-content d:/temp/acronyms.txt# read file of acronym | definition foreach ( $l in $d ) { ($acro, $def) = $l.split('|')# build array of acronym, definition make-change $acro $def } Finished $objWord.Selection.HomeKey(6) Null ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE on MS Word using Selection.Find.Execute
On Sun, 12 Sep 2010, Peter Buck wrote: Does anyone have an example of a perl script acting on MS Word documents using Win32::OLE and Selection.Find.Execute? Actually, I do, and it is even part of the Win32::OLE module distribution on CPAN. But since it is not being installed with the actual module itself it is somewhat hard to find: http://cpansearch.perl.org/src/JDB/Win32-OLE-0.1709/eg/word2pod.pl The script takes a Word document and tries to convert it to POD. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: WIN32::OLE WMI Out params
On Fri, 04 Dec 2009 17:10:26 -0800, Michael Ellery mi...@s2technologies.com wrote: Michael wrote: Okay - Just to sum up the whole thing. The original VBScript EOF; Option Explicit Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes, objItem Set objWMIService = GetObject(winmgmts:root\HewlettPackard\OpenView\data) Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True) WScript.Echo Child Group Count: objChildGroups vbCrLF For Each objItem In arrNodes WScript.Echo Name: objItem.Name Next EOF Returns the following: Child Group Count: 25 Name: {36716FD8-E600-46FB-90CA-1263E0C62509} Name: {38FF8E8E-2DDC-4895-A7EB-0DC7DF50EC25} Name: {3E575181-0225-4553-9722-46F841B9FA76} Name: {8A412133-F571-42BC-8A66-4B242EB3BAC4} Name: {E14D965C-1FBB-40EC-A784-5F9F39F82281} Name: OpenView_AIX Name: OpenView_External Name: OpenView_HPUX Name: OpenView_Linux Name: OpenView_NNM Name: OpenView_OpenVMS Name: OpenView_OpenVMS(itanium) Name: OpenView_SNMP Name: OpenView_Solaris Name: OpenView_Tru64 Name: OpenView_Unknown Name: OpenView_Windows2000 Name: OpenView_WindowsNT Name: OpenView_WindowsServer2003 Name: OpenView_WindowsServer2008 Name: OpenView_WindowsVista Name: OpenView_WindowsXP Name: Root_Special Name: Root_Unix Name: Root_Windows And the Perl-Script with the modification EOF; #!perl use strict; use warnings; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Data::Dumper; my $objWMIService = Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or die WMI connection failed.\n; if (Win32::OLE- LastError() != 0) { print Error calling GetObject: . Win32::OLE-LastError() . \n; exit 0; } my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup); if (Win32::OLE- LastError() != 0) { print Error calling Get: . Win32::OLE-LastError() . \n; exit 0; } my $objGetRoot = $objOV_NodeGroup-GetRoot(); if (Win32::OLE- LastError() != 0) { print Error calling GetRoot: . Win32::OLE-LastError() . \n; exit 0; } my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, True); if (Win32::OLE- LastError() != 0) { print Error calling GetChildNodeGroups: . Win32::OLE-LastError() . \n; exit 0; } print Child Group Count: . $objChildGroups . \n; print Dumper($nodes); foreach my $objItem (in $nodes) { print 'Name: ' . $objItem-{Name} . \n; } #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197068)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197828)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27198308)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); Returns ##Error calling GetChildNodeGroups: Win32::OLE(0.1709) error 0x80010105: The server threw an exception ##in METHOD/PROPERTYGET GetChildNodeGroups #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199076)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197684)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199620)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199524)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. Does any of this, make any sense to you guys? /Michael so, it looks like your Dumper statement is indicating a valid object in
Re: WIN32::OLE WMI Out params
On Sat, 05 Dec 2009 05:58:48 -0800, Michael Ellery mi...@s2technologies.com wrote: Michael wrote: On Fri, 04 Dec 2009 17:10:26 -0800, Michael Ellery mi...@s2technologies.com wrote: Michael wrote: Okay - Just to sum up the whole thing. The original VBScript EOF; Option Explicit Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes, objItem Set objWMIService = GetObject(winmgmts:root\HewlettPackard\OpenView\data) Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True) WScript.Echo Child Group Count: objChildGroups vbCrLF For Each objItem In arrNodes WScript.Echo Name: objItem.Name Next EOF Returns the following: Child Group Count: 25 Name: {36716FD8-E600-46FB-90CA-1263E0C62509} Name: {38FF8E8E-2DDC-4895-A7EB-0DC7DF50EC25} Name: {3E575181-0225-4553-9722-46F841B9FA76} Name: {8A412133-F571-42BC-8A66-4B242EB3BAC4} Name: {E14D965C-1FBB-40EC-A784-5F9F39F82281} Name: OpenView_AIX Name: OpenView_External Name: OpenView_HPUX Name: OpenView_Linux Name: OpenView_NNM Name: OpenView_OpenVMS Name: OpenView_OpenVMS(itanium) Name: OpenView_SNMP Name: OpenView_Solaris Name: OpenView_Tru64 Name: OpenView_Unknown Name: OpenView_Windows2000 Name: OpenView_WindowsNT Name: OpenView_WindowsServer2003 Name: OpenView_WindowsServer2008 Name: OpenView_WindowsVista Name: OpenView_WindowsXP Name: Root_Special Name: Root_Unix Name: Root_Windows And the Perl-Script with the modification EOF; #!perl use strict; use warnings; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Data::Dumper; my $objWMIService = Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or die WMI connection failed.\n; if (Win32::OLE- LastError() != 0) { print Error calling GetObject: . Win32::OLE-LastError() . \n; exit 0; } my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup); if (Win32::OLE- LastError() != 0) { print Error calling Get: . Win32::OLE-LastError() . \n; exit 0; } my $objGetRoot = $objOV_NodeGroup-GetRoot(); if (Win32::OLE- LastError() != 0) { print Error calling GetRoot: . Win32::OLE-LastError() . \n; exit 0; } my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, True); if (Win32::OLE- LastError() != 0) { print Error calling GetChildNodeGroups: . Win32::OLE-LastError() . \n; exit 0; } print Child Group Count: . $objChildGroups . \n; print Dumper($nodes); foreach my $objItem (in $nodes) { print 'Name: ' . $objItem-{Name} . \n; } #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197068)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197828)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27198308)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); Returns ##Error calling GetChildNodeGroups: Win32::OLE(0.1709) error 0x80010105: The server threw an exception ##in METHOD/PROPERTYGET GetChildNodeGroups #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199076)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197684)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199620)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199524)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. Does any of this, make any sense to you guys? /Michael so, it looks
RE: WIN32::OLE WMI Out params
Below... -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Michael Sent: Thursday, December 03, 2009 6:45 AM To: perl-win32-users@listserv.ActiveState.com Subject: RE: WIN32::OLE WMI Out params When troubleshooting OLE issues, it is best to have the following code after each OLE command... If (Win32::OLE- LastError() != 0) { print error calling blah: . Win32::OLE- LastError() . \n; exit 0; } ...Or something similar, so you can see what OLE had issues with (if anything). It might lead you in a direction that fixes it. Steven Added to the script, but no issues reported. /Michael Well, then my next guess is the use of the Variant module (because no error is thrown from OLE). Some OLE calls require to be cast of a certain type before they work. use Win32::OLE::Variant; my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0); #I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of VT_ARRAY|VT_VARIANT #then my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE); Play around with this... I'm not the greatest Variant script writer here, to know exactly which combination will work (if this is it) based on the object type as I've only run into this a few times before, but you can get examples from your perl install here (depending on your perl build version) of similar options to try and all the VT_* types: C:\Perl\html\lib\Win32\OLE\Variant.html HTH P.S. I googled OV_NodeGroup and found someone else with your same problem on an HP board (or so it seems). :( Steven ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
Hi Steven, Well I tried your suggestion and I think that the Win32::OLE::Variant module might be the solution, as I have found some other examples where WMI [out] and variants are used. http://www.infoqu.com/dev/perl-programming/using-perl-with-wmi-to-set-folder-level-permissions-16930-1/ http://www.perlmonks.org/?node_id=325823 However I'm in way over my head here, so unless someone could cut it out in pieces , I don't think that I'll get any further. /Michael On Fri, 4 Dec 2009 02:12:03 -0700, Steven Manross ste...@manross.net wrote: Below... -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Michael Sent: Thursday, December 03, 2009 6:45 AM To: perl-win32-users@listserv.ActiveState.com Subject: RE: WIN32::OLE WMI Out params When troubleshooting OLE issues, it is best to have the following code after each OLE command... If (Win32::OLE- LastError() != 0) { print error calling blah: . Win32::OLE- LastError() . \n; exit 0; } ...Or something similar, so you can see what OLE had issues with (if anything). It might lead you in a direction that fixes it. Steven Added to the script, but no issues reported. /Michael Well, then my next guess is the use of the Variant module (because no error is thrown from OLE). Some OLE calls require to be cast of a certain type before they work. use Win32::OLE::Variant; my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0); #I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of VT_ARRAY|VT_VARIANT #then my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE); Play around with this... I'm not the greatest Variant script writer here, to know exactly which combination will work (if this is it) based on the object type as I've only run into this a few times before, but you can get examples from your perl install here (depending on your perl build version) of similar options to try and all the VT_* types: C:\Perl\html\lib\Win32\OLE\Variant.html HTH P.S. I googled OV_NodeGroup and found someone else with your same problem on an HP board (or so it seems). :( Steven ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: WIN32::OLE WMI Out params
I haven't followed your thread closely, but it seems like the relevant bits from your first link are these: my $objSecDescriptor = Win32::OLE::Variant- new (VT_DISPATCH|VT_BYREF); my $retval = $objDirectorySecSetting-GetSecurityDescriptor($objSecDescriptor); ..which seems to be filling the $objSecDescriptor with an out param. If your out param is an array, you might need to add VT_ARRAY to the variant flags when you create it. Does something like that work for you ? -Mike Michael wrote: Hi Steven, Well I tried your suggestion and I think that the Win32::OLE::Variant module might be the solution, as I have found some other examples where WMI [out] and variants are used. http://www.infoqu.com/dev/perl-programming/using-perl-with-wmi-to-set-folder-level-permissions-16930-1/ http://www.perlmonks.org/?node_id=325823 However I'm in way over my head here, so unless someone could cut it out in pieces , I don't think that I'll get any further. /Michael On Fri, 4 Dec 2009 02:12:03 -0700, Steven Manross ste...@manross.net wrote: Below... -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Michael Sent: Thursday, December 03, 2009 6:45 AM To: perl-win32-users@listserv.ActiveState.com Subject: RE: WIN32::OLE WMI Out params When troubleshooting OLE issues, it is best to have the following code after each OLE command... If (Win32::OLE- LastError() != 0) { print error calling blah: . Win32::OLE- LastError() . \n; exit 0; } ...Or something similar, so you can see what OLE had issues with (if anything). It might lead you in a direction that fixes it. Steven Added to the script, but no issues reported. /Michael Well, then my next guess is the use of the Variant module (because no error is thrown from OLE). Some OLE calls require to be cast of a certain type before they work. use Win32::OLE::Variant; my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0); #I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of VT_ARRAY|VT_VARIANT #then my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE); Play around with this... I'm not the greatest Variant script writer here, to know exactly which combination will work (if this is it) based on the object type as I've only run into this a few times before, but you can get examples from your perl install here (depending on your perl build version) of similar options to try and all the VT_* types: C:\Perl\html\lib\Win32\OLE\Variant.html HTH P.S. I googled OV_NodeGroup and found someone else with your same problem on an HP board (or so it seems). :( Steven ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
-Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Michael Ellery Sent: Friday, December 04, 2009 11:59 AM To: Michael Cc: perl-win32-users@listserv.ActiveState.com Subject: Re: WIN32::OLE WMI Out params I haven't followed your thread closely, but it seems like the relevant bits from your first link are these: my $objSecDescriptor = Win32::OLE::Variant- new (VT_DISPATCH|VT_BYREF); my $retval = $objDirectorySecSetting-GetSecurityDescriptor($objSecDescriptor); ..which seems to be filling the $objSecDescriptor with an out param. If your out param is an array, you might need to add VT_ARRAY to the variant flags when you create it. Does something like that work for you ? -Mike Michael wrote: Hi Steven, Well I tried your suggestion and I think that the Win32::OLE::Variant module might be the solution, as I have found some other examples where WMI [out] and variants are used. http://www.infoqu.com/dev/perl-programming/using-perl-with-wmi-to-set- folder-level-permissions-16930-1/ http://www.perlmonks.org/?node_id=325823 However I'm in way over my head here, so unless someone could cut it out in pieces , I don't think that I'll get any further. /Michael On Fri, 4 Dec 2009 02:12:03 -0700, Steven Manross ste...@manross.net wrote: Below... -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Michael Sent: Thursday, December 03, 2009 6:45 AM To: perl-win32-users@listserv.ActiveState.com Subject: RE: WIN32::OLE WMI Out params When troubleshooting OLE issues, it is best to have the following code after each OLE command... If (Win32::OLE- LastError() != 0) { print error calling blah: . Win32::OLE- LastError() . \n; exit 0; } ...Or something similar, so you can see what OLE had issues with (if anything). It might lead you in a direction that fixes it. Steven Added to the script, but no issues reported. /Michael Well, then my next guess is the use of the Variant module (because no error is thrown from OLE). Some OLE calls require to be cast of a certain type before they work. my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0); My apologies here.. I think that I misstated the way to call it. Put this at the top somewhere... use Win32::OLE::Variant; Add the following before your GetChildNodes call. Thanks go to Michael Ellery for making me see that mistake as I did not test this code before sending it off. my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); By adding this before your GetChildNodes call, you should be all set (Variant-wise) However, before you give up after trying the above call (if it does not work as stated above), I would replace: VT_ARRAY|VT_VARIANT With VT_VARIANT And also try.. (if the previous does not work) VT_ARRAY|VT_BSTR And lastly try his example from the SecurityDescriptor call.. VT_DISPATCH|VT_BYREF ...in my code above. As well, you might try sticking the VT_BYREF as another ORed option to each of the above examples like in Michael Ellery's example.. i.e. VT_ARRAY_|VT_BSTR|VT_BYREF or VT_VARIANT|VT_BYREF or VT_ARRAY|VT_VARIANT|VT_BYREF HTH Steven #I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of VT_ARRAY|VT_VARIANT #then my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE); Play around with this... I'm not the greatest Variant script writer here, to know exactly which combination will work (if this is it) based on the object type as I've only run into this a few times before, but you can get examples from your perl install here (depending on your perl build version) of similar options to try and all the VT_* types: C:\Perl\html\lib\Win32\OLE\Variant.html HTH P.S. I googled OV_NodeGroup and found someone else with your same problem on an HP board (or so it seems). :( Steven ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
Okay - Just to sum up the whole thing. The original VBScript EOF; Option Explicit Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes, objItem Set objWMIService = GetObject(winmgmts:root\HewlettPackard\OpenView\data) Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True) WScript.Echo Child Group Count: objChildGroups vbCrLF For Each objItem In arrNodes WScript.Echo Name: objItem.Name Next EOF Returns the following: Child Group Count: 25 Name: {36716FD8-E600-46FB-90CA-1263E0C62509} Name: {38FF8E8E-2DDC-4895-A7EB-0DC7DF50EC25} Name: {3E575181-0225-4553-9722-46F841B9FA76} Name: {8A412133-F571-42BC-8A66-4B242EB3BAC4} Name: {E14D965C-1FBB-40EC-A784-5F9F39F82281} Name: OpenView_AIX Name: OpenView_External Name: OpenView_HPUX Name: OpenView_Linux Name: OpenView_NNM Name: OpenView_OpenVMS Name: OpenView_OpenVMS(itanium) Name: OpenView_SNMP Name: OpenView_Solaris Name: OpenView_Tru64 Name: OpenView_Unknown Name: OpenView_Windows2000 Name: OpenView_WindowsNT Name: OpenView_WindowsServer2003 Name: OpenView_WindowsServer2008 Name: OpenView_WindowsVista Name: OpenView_WindowsXP Name: Root_Special Name: Root_Unix Name: Root_Windows And the Perl-Script with the modification EOF; #!perl use strict; use warnings; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Data::Dumper; my $objWMIService = Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or die WMI connection failed.\n; if (Win32::OLE- LastError() != 0) { print Error calling GetObject: . Win32::OLE-LastError() . \n; exit 0; } my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup); if (Win32::OLE- LastError() != 0) { print Error calling Get: . Win32::OLE-LastError() . \n; exit 0; } my $objGetRoot = $objOV_NodeGroup-GetRoot(); if (Win32::OLE- LastError() != 0) { print Error calling GetRoot: . Win32::OLE-LastError() . \n; exit 0; } my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, True); if (Win32::OLE- LastError() != 0) { print Error calling GetChildNodeGroups: . Win32::OLE-LastError() . \n; exit 0; } print Child Group Count: . $objChildGroups . \n; print Dumper($nodes); foreach my $objItem (in $nodes) { print 'Name: ' . $objItem-{Name} . \n; } #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197068)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197828)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27198308)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); Returns ##Error calling GetChildNodeGroups: Win32::OLE(0.1709) error 0x80010105: The server threw an exception ##in METHOD/PROPERTYGET GetChildNodeGroups #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199076)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197684)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199620)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199524)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. Does any of this, make any sense to you guys? /Michael ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: WIN32::OLE WMI Out params
Michael wrote: Okay - Just to sum up the whole thing. The original VBScript EOF; Option Explicit Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes, objItem Set objWMIService = GetObject(winmgmts:root\HewlettPackard\OpenView\data) Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True) WScript.Echo Child Group Count: objChildGroups vbCrLF For Each objItem In arrNodes WScript.Echo Name: objItem.Name Next EOF Returns the following: Child Group Count: 25 Name: {36716FD8-E600-46FB-90CA-1263E0C62509} Name: {38FF8E8E-2DDC-4895-A7EB-0DC7DF50EC25} Name: {3E575181-0225-4553-9722-46F841B9FA76} Name: {8A412133-F571-42BC-8A66-4B242EB3BAC4} Name: {E14D965C-1FBB-40EC-A784-5F9F39F82281} Name: OpenView_AIX Name: OpenView_External Name: OpenView_HPUX Name: OpenView_Linux Name: OpenView_NNM Name: OpenView_OpenVMS Name: OpenView_OpenVMS(itanium) Name: OpenView_SNMP Name: OpenView_Solaris Name: OpenView_Tru64 Name: OpenView_Unknown Name: OpenView_Windows2000 Name: OpenView_WindowsNT Name: OpenView_WindowsServer2003 Name: OpenView_WindowsServer2008 Name: OpenView_WindowsVista Name: OpenView_WindowsXP Name: Root_Special Name: Root_Unix Name: Root_Windows And the Perl-Script with the modification EOF; #!perl use strict; use warnings; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Data::Dumper; my $objWMIService = Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or die WMI connection failed.\n; if (Win32::OLE- LastError() != 0) { print Error calling GetObject: . Win32::OLE-LastError() . \n; exit 0; } my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup); if (Win32::OLE- LastError() != 0) { print Error calling Get: . Win32::OLE-LastError() . \n; exit 0; } my $objGetRoot = $objOV_NodeGroup-GetRoot(); if (Win32::OLE- LastError() != 0) { print Error calling GetRoot: . Win32::OLE-LastError() . \n; exit 0; } my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, True); if (Win32::OLE- LastError() != 0) { print Error calling GetChildNodeGroups: . Win32::OLE-LastError() . \n; exit 0; } print Child Group Count: . $objChildGroups . \n; print Dumper($nodes); foreach my $objItem (in $nodes) { print 'Name: ' . $objItem-{Name} . \n; } #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197068)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197828)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27198308)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); Returns ##Error calling GetChildNodeGroups: Win32::OLE(0.1709) error 0x80010105: The server threw an exception ##in METHOD/PROPERTYGET GetChildNodeGroups #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199076)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197684)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199620)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199524)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. Does any of this, make any sense to you guys? /Michael so, it looks like your Dumper statement is indicating a valid object in most cases. I think the problem on your loop is that you are using the 'in' adapter,
RE: WIN32::OLE WMI Out params
Michael wrote: Hi, I'm a novice regarding Perl, and need some help converting a VBScript to a PerlScript. The following VBScript returns some data from HP OpenView. The GetChildNodeGroups method returns the number of ChildGroups, and the [out] parameter NodeGroups returns an array which contains a list of OV_NodeGroup. From the documentation: sint32 GetChildNodeGroups( [out] OV_NodeGroup NodeGroups[], [in, optional] boolean IncludeSubGroups) Description Returns a list of node groups (instances of OV_NodeGroup) that are children of this node group. Return Value Number of node groups (children) in the out parameter NodeGroups. ' VBScript Begin Option Explicit Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes, objItem Set objWMIService = GetObject(winmgmts:root\HewlettPackard\OpenView\data) Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True) WScript.Echo Child Group Count: objChildGroups vbCrLF For Each objItem In arrNodes WScript.Echo Name: objItem.Name Next ' VBScript End The problem is that I can't find out how to get the array (@arrNodes) in Perl. # PerlScript Begin use strict; use warnings; use Win32::OLE qw(in with); use Data::Dumper; my $objWMIService = Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or die WMI connection failed.\n; my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup); my $objGetRoot = $objOV_NodeGroup-GetRoot(); my @arrNodes; my $objChildGroups = $objGetRoot-GetChildNodeGroups(@arrNodes, True); And you were doing so well up to this point. I really don't think that you want to pass an empty array, interpolated into a string, as an output parameter. In fact, I would expect that it might even produce a run-time error. Does it? I don't know the answer, but from my limited Perl/OLE experience, my first guess would be that the function would want to return an OLE container object in the output parameter, and so would expect it to be a reference to a scalar. For example: my $nodes; use constant TRUE = 1; my $objChildGroups = $objGetRoot-GetChildNodeGroups(\$nodes, TRUE); print Child Group Count: . $objChildGroups . \n; print @arrNodes . \n; If I am right, and I may well not be, this would probably need to be something like: for my $obj (in $nodes) { print Name: $obj-{Name}\n; } # PerlScript End Any help would be appreciated. HTH, in lieu of somebody coming up with a more certain answer. -- Brian Raven This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
Michael wrote: Hi, I'm a novice regarding Perl, and need some help converting a VBScript to a PerlScript. The following VBScript returns some data from HP OpenView. The GetChildNodeGroups method returns the number of ChildGroups, and the [out] parameter NodeGroups returns an array which contains a list of OV_NodeGroup. From the documentation: sint32 GetChildNodeGroups( [out] OV_NodeGroup NodeGroups[], [in, optional] boolean IncludeSubGroups) Description Returns a list of node groups (instances of OV_NodeGroup) that are children of this node group. Return Value Number of node groups (children) in the out parameter NodeGroups. ' VBScript Begin Option Explicit Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes, objItem Set objWMIService = GetObject(winmgmts:root\HewlettPackard\OpenView\data) Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True) WScript.Echo Child Group Count: objChildGroups vbCrLF For Each objItem In arrNodes WScript.Echo Name: objItem.Name Next ' VBScript End The problem is that I can't find out how to get the array (@arrNodes) in Perl. # PerlScript Begin use strict; use warnings; use Win32::OLE qw(in with); use Data::Dumper; my $objWMIService = Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or die WMI connection failed.\n; my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup); my $objGetRoot = $objOV_NodeGroup-GetRoot(); my @arrNodes; my $objChildGroups = $objGetRoot-GetChildNodeGroups(@arrNodes, True); And you were doing so well up to this point. I really don't think that you want to pass an empty array, interpolated into a string, as an output parameter. In fact, I would expect that it might even produce a run-time error. Does it? Nope it does not. The problem is still that @arrNodes is empty. The GetChildNodeGroups method does not populate the variable/array like it does in VBScript. Therefore I've been around @arrNodes, \...@arrnodes, $nodes etc... I don't know the answer, but from my limited Perl/OLE experience, my first guess would be that the function would want to return an OLE container object in the output parameter, and so would expect it to be a reference to a scalar. For example: my $nodes; use constant TRUE = 1; my $objChildGroups = $objGetRoot- GetChildNodeGroups(\$nodes, TRUE); print Child Group Count: . $objChildGroups . \n; print @arrNodes . \n; If I am right, and I may well not be, this would probably need to be something like: for my $obj (in $nodes) { print Name: $obj- {Name}\n; } Yep - but because $nodes/@arrNodes is empty this does not change much. # PerlScript End Any help would be appreciated. HTH, in lieu of somebody coming up with a more certain answer. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
When troubleshooting OLE issues, it is best to have the following code after each OLE command... If (Win32::OLE-LastError() != 0) { print error calling blah: . Win32::OLE-LastError() . \n; exit 0; } ...Or something similar, so you can see what OLE had issues with (if anything). It might lead you in a direction that fixes it. Steven -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Michael Sent: Thursday, December 03, 2009 6:19 AM To: perl-win32-users@listserv.ActiveState.com Subject: RE: WIN32::OLE WMI Out params Michael wrote: Hi, I'm a novice regarding Perl, and need some help converting a VBScript to a PerlScript. The following VBScript returns some data from HP OpenView. The GetChildNodeGroups method returns the number of ChildGroups, and the [out] parameter NodeGroups returns an array which contains a list of OV_NodeGroup. From the documentation: sint32 GetChildNodeGroups( [out] OV_NodeGroup NodeGroups[], [in, optional] boolean IncludeSubGroups) Description Returns a list of node groups (instances of OV_NodeGroup) that are children of this node group. Return Value Number of node groups (children) in the out parameter NodeGroups. ' VBScript Begin Option Explicit Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes, objItem Set objWMIService = GetObject(winmgmts:root\HewlettPackard\OpenView\data) Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True) WScript.Echo Child Group Count: objChildGroups vbCrLF For Each objItem In arrNodes WScript.Echo Name: objItem.Name Next ' VBScript End The problem is that I can't find out how to get the array (@arrNodes) in Perl. # PerlScript Begin use strict; use warnings; use Win32::OLE qw(in with); use Data::Dumper; my $objWMIService = Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or die WMI connection failed.\n; my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup); my $objGetRoot = $objOV_NodeGroup-GetRoot(); my @arrNodes; my $objChildGroups = $objGetRoot-GetChildNodeGroups(@arrNodes, True); And you were doing so well up to this point. I really don't think that you want to pass an empty array, interpolated into a string, as an output parameter. In fact, I would expect that it might even produce a run-time error. Does it? Nope it does not. The problem is still that @arrNodes is empty. The GetChildNodeGroups method does not populate the variable/array like it does in VBScript. Therefore I've been around @arrNodes, \...@arrnodes, $nodes etc... I don't know the answer, but from my limited Perl/OLE experience, my first guess would be that the function would want to return an OLE container object in the output parameter, and so would expect it to be a reference to a scalar. For example: my $nodes; use constant TRUE = 1; my $objChildGroups = $objGetRoot- GetChildNodeGroups(\$nodes, TRUE); print Child Group Count: . $objChildGroups . \n; print @arrNodes . \n; If I am right, and I may well not be, this would probably need to be something like: for my $obj (in $nodes) { print Name: $obj- {Name}\n; } Yep - but because $nodes/@arrNodes is empty this does not change much. # PerlScript End Any help would be appreciated. HTH, in lieu of somebody coming up with a more certain answer. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
When troubleshooting OLE issues, it is best to have the following code after each OLE command... If (Win32::OLE- LastError() != 0) { print error calling blah: . Win32::OLE- LastError() . \n; exit 0; } ...Or something similar, so you can see what OLE had issues with (if anything). It might lead you in a direction that fixes it. Steven Added to the script, but no issues reported. /Michael ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE help
Hello Steve, It does work and my machine shows the same values for minimise and maximise .. But what does these value depend on ? I checked in another machine and the maximise value is -4137 ... Where do i find the constants declared for these ? Thanks and Regards Maxmelbin Neson From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Howard (PFE) Sent: Friday, 15. August 2008 1:34 AM To: Neson Maxmelbin (RBEI/EMT4); perl-win32-users@listserv.ActiveState.com Subject: RE: WIN32::OLE help I'll type this directly in so I might make a typo. You should be able to set the state in the application object: $Excel-{WindowState} = -4140; To set back to normal mode: $Excel-{WindowState} = -4143; The way to find this is to record a macro in Excel, and do what you want to see. Then view the macros and see what was done. In this case, the macro uses constants xlMinimized, and xlNormal. You can use the object browser to see the values of those constants. They're probably in the constants you have imported as well, so it would probably be better to use them there rather than the literal values. See if this helps. Steve From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Neson Maxmelbin (RBEI/EMT4) Sent: Thursday, August 14, 2008 4:30 AM To: perl-win32-users@listserv.ActiveState.com Subject: WIN32::OLE help Hello , I am using WIn32::OLE to Read contents of an Excel sheet. There is no issues on reading, but the problem is that Excel file opens on the screen, during the time the script processes the file. I don't need this. One solution was to make it not visible ($Excel-{'Visible'} = 0;). But this had some other problems. In some cases, when this Excel sheet was open for viewing, its contents were hidden ! , when we move the mouse over the cells, then we see it .. might be a Excel Bug. Due this we cannot make the Excel sheet invisible during the runnign of the script. What I need now is to minimise the sheet once it is opened. How do we do it ? My code extract - use Win32::OLE::Const 'Microsoft Excel'; $Excel = Win32::OLE-GetActiveObject('Excel.Application')|| Win32::OLE-new('Excel.Application', 'Quit'); $Excel-{'Visible'} = 1; $xlFile = 'C:\HWEConfig.xls'; eval { $Book = $Excel-Workbooks-Open($xlFile); }; ... then the reading Thanks and Regards Maxmelbin Neson ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE help
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Neson Maxmelbin (RBEI/EMT4) Sent: 18 August 2008 09:40 To: Steve Howard (PFE); perl-win32-users@listserv.ActiveState.com Subject: RE: WIN32::OLE help Hello Steve, It does work and my machine shows the same values for minimise and maximise .. But what does these value depend on ? I checked in another machine and the maximise value is -4137 ... Where do i find the constants declared for these ? They are declared by the module that you have already included, i.e. Win32::OLE::Const. See the documentation for that module (you should probably have done that before using it in your code). However, as I am feeling generous, try either: use Win32::OLE::Const 'Microsoft Excel'; print xlMaximized: , xlMaximized, \n; print xlMinimized: , xlMinimized, \n; print xlNormal: , xlNormal, \n; ... or if you don't want to polute your main namespace so much try this: use Win32::OLE::Const; my $consts = Win32::OLE::Const-Load('Microsoft Excel'); print xlMaximized: $consts-{xlMaximized}\n; print xlMinimized: $consts-{xlMinimized}\n; print xlNormal: $consts-{xlNormal}\n; To find the constant names, or anything to do with using OLE on such applications, it is useful to read the relevant parts of the Visual Basic Reference for that application, under the help menu. Another damned useful tool is the OLE browser kindly provided with the Activestate documentation. I found the constant names mentioned above in both. HTH -- Brian Raven Visit our website at http://www.nyse.com Note: The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system. Thank you. NYSE Group, Inc. __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: WIN32::OLE help
Hello, if you just want to read data from an Excel file, you might consider the Spreadsheet::ParseExcel module. I would think that using the OLE module always starts an Excel instance (visible or not) whereas the Spreadsheet module operates directly on the XLS file. Ekkehard _ CONFIDENTIALITY NOTICE The information contained in this e-mail message is intended only for the exclusive use of the individual or entity named above and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivery of the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by e-mail and delete the material from any computer. Thank you. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE help
I'll type this directly in so I might make a typo. You should be able to set the state in the application object: $Excel-{WindowState} = -4140; To set back to normal mode: $Excel-{WindowState} = -4143; The way to find this is to record a macro in Excel, and do what you want to see. Then view the macros and see what was done. In this case, the macro uses constants xlMinimized, and xlNormal. You can use the object browser to see the values of those constants. They're probably in the constants you have imported as well, so it would probably be better to use them there rather than the literal values. See if this helps. Steve From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Neson Maxmelbin (RBEI/EMT4) Sent: Thursday, August 14, 2008 4:30 AM To: perl-win32-users@listserv.ActiveState.com Subject: WIN32::OLE help Hello , I am using WIn32::OLE to Read contents of an Excel sheet. There is no issues on reading, but the problem is that Excel file opens on the screen, during the time the script processes the file. I don't need this. One solution was to make it not visible ($Excel-{'Visible'} = 0;). But this had some other problems. In some cases, when this Excel sheet was open for viewing, its contents were hidden ! , when we move the mouse over the cells, then we see it .. might be a Excel Bug. Due this we cannot make the Excel sheet invisible during the runnign of the script. What I need now is to minimise the sheet once it is opened. How do we do it ? My code extract - use Win32::OLE::Const 'Microsoft Excel'; $Excel = Win32::OLE-GetActiveObject('Excel.Application')|| Win32::OLE-new('Excel.Application', 'Quit'); $Excel-{'Visible'} = 1; $xlFile = 'C:\HWEConfig.xls'; eval { $Book = $Excel-Workbooks-Open($xlFile); }; ... then the reading Thanks and Regards Maxmelbin Neson ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE -- assignment to property of type IUnknown..how?
On Wed, 28 May 2008, Michael Ellery wrote: I have a COM component with a property defined like this (IDL): [propput, id(30), helpstring(property TestSuite)] HRESULT TestSuite([in] IUnknown *pVal); Try adding a second line here: [propputref, id(30), helpstring(property TestSuite)] HRESULT TestSuite([in] IUnknown *pVal); (identical to the previous line, except propput = propputref). Not sure if this is enough, but maybe it is sufficient to get the required IDispatch glue generated for you. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE problem
Removing the trailing semi-colon did the trick. From: Howard Tanner [mailto:[EMAIL PROTECTED] It's been a while, so I looked it up. From MS: LDAP://DC=Fabrikam,DC=com;(objectClass=*);AdsPath, cn;subTree So remove the space before subTree and the semi-colon following it. If that still doesn't work, your query might be case sensitive, so fix the capitalization for subTree. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE and VT_INT
On Wed, 09 Jan 2008, Michael Ellery wrote: just running some quick COM code in perl and I notice this: if I call a property or method that returns VT_I4, Win32::OLE maps that to a perl integer in scalar context. When I call a property or method that returns VT_INT, however, it gets mapped to a perl string. Is this deliberate? Is it correct behavior? I can work around my current issue by just doing int() around my values, but it seemed strange to me that these two cases produced slightly different scalars. It is a bug in Win32::OLE: it doesn't handle VT_INT (nor VT_UINT) explicitly and therefore tries to coerce it into VT_BSTR (using VariantChangeTypeEx) before turning it into a Perl scalar. At the Perl level this shouldn't really matter though, as strings are converted back to integers/numbers automatically whenever needed. I don't know why it was never handled explicitly; I just checked, and even the wtypes.h from VC98 lists VT_INT as a valid type for a VARIANT. I'll fix it in a future Win32::OLE release. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE and VT_INT
Jan Dubois wrote: On Wed, 09 Jan 2008, Michael Ellery wrote: just running some quick COM code in perl and I notice this: if I call a property or method that returns VT_I4, Win32::OLE maps that to a perl integer in scalar context. When I call a property or method that returns VT_INT, however, it gets mapped to a perl string. Is this deliberate? Is it correct behavior? I can work around my current issue by just doing int() around my values, but it seemed strange to me that these two cases produced slightly different scalars. It is a bug in Win32::OLE: it doesn't handle VT_INT (nor VT_UINT) explicitly and therefore tries to coerce it into VT_BSTR (using VariantChangeTypeEx) before turning it into a Perl scalar. At the Perl level this shouldn't really matter though, as strings are converted back to integers/numbers automatically whenever needed. I don't know why it was never handled explicitly; I just checked, and even the wtypes.h from VC98 lists VT_INT as a valid type for a VARIANT. I'll fix it in a future Win32::OLE release. Cheers, -Jan Jan, Thanks for the quick response. In my case, I only noticed the behavior because I am passing the output to another property - and that property put wasn't expecting a string. It went something like this: my $foo = $oleObject-Some_VT_INT_Property; $oleObject-{Some_VARIANT_Property} = $foo; The VT_TYPE coming into my put_Some_VARIANT_Property was actually VT_BSTR in this case, which I was not expecting. Simply wrapping int() around the get call works fine, but a fix to Win32::OLE would be great. I think I'll also update my VARIANT processing on the put. Thanks, Mike ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE and VT_INT
On Wed, 09 Jan 2008, Michael Ellery wrote: The VT_TYPE coming into my put_Some_VARIANT_Property was actually VT_BSTR in this case, which I was not expecting. Simply wrapping int() around the get call works fine, but a fix to Win32::OLE would be great. I think I'll also update my VARIANT processing on the put. I think you should do that. I don't know if there is some normative text about this, but I've seen several references that say that the IDispatch::Invoke implementation is responsible for the coercion of all parameters to the expected type (if possible). E.g. the remarks section of the VariantChangeTypeEx() documentation says: | Typically, the implementer of IDispatch::Invoke determines which | member is being accessed and then calls VariantChangeType to get the | value of one or more arguments. | | For example, if the IDispatch call specifies a SetTitle member that | takes one string argument, the implementor would call | VariantChangeTypeEx to attempt to coerce the argument to VT_BSTR. [from http://msdn2.microsoft.com/en-us/library/aa909107.aspx] Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: win32::ole (excel) question
Hi Jan, You're abolutely right - I forgot I had changed the name I was using to set Sheet1. I changed to a shorter length and it's running perfect. Thanks much. Dave Kazatsky Senior Middleware Engineer NSE - Solutions Engineering W. (732) 893-4351 C. (973) 865-8106 Jan Dubois [EMAIL PROTECTED] .com To [EMAIL PROTECTED], 08/10/2007 02:22 [EMAIL PROTECTED] PMte.com cc Subject RE: win32::ole (excel) question The first sheet name is never changed from “Sheet1” to begin with because you are trying to set it to a name with 37 characters. The maximum sheet name length in Excel is 31 characters. It would be nice if Excel returned an error if you try to assign an invalid name, but it doesn’t appear to do so. Cheers, -Jan From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: August 10, 2007 10:30 AM To: perl-win32-users@listserv.ActiveState.com Subject: win32::ole (excel) question Hi all, Weird situation with creating new worksheets and keeping the title in the tab. I f I create just one everything is fine - when I add a second worksheet to the workbook the title goes away from the original worksheet. Code excerpt: This is where the object is instanciated and the first worksheet is created and named: #--create and open the first worksheet my $excel = Win32::OLE-new(Excel.Application); $excel-{Visible} = 1; my $book = $excel-Workbooks-Add; my $sheet = $book-Worksheets(1); $sheet-{Name} = Daily Message Volume By Queue Manager; **cells are filled in and formatted - everything looks great to this point Here'e where the next worksheet is added: #--create and open the second worksheet $sheet = $book-Worksheets-Add; $sheet-{Name} = Daily Message Volume By Queue; $sheet-Columns-{ColumnWidth} = 24; **When this worksheet is created the first worksheet goes back to being named Sheet1 Any thoughts greatly appreciated. Thanks in advance. Dave Kazatsky Senior Middleware Engineer NSE - Solutions Engineering W. (732) 893-4351 C. (973) 865-8106 The information contained in this message may be CONFIDENTIAL and is for the intended addressee only. Any unauthorized use, dissemination of the information, or copying of this message is prohibited. If you are not the intended addressee, please notify the sender immediately and delete this message. The information contained in this message may be CONFIDENTIAL and is for the intended addressee only. Any unauthorized use, dissemination of the information, or copying of this message is prohibited. If you are not the intended addressee, please notify the sender immediately and delete this message. inline: graycol.gifinline: pic26421.gifinline: ecblank.gif___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: win32::ole (excel) question
The first sheet name is never changed from Sheet1 to begin with because you are trying to set it to a name with 37 characters. The maximum sheet name length in Excel is 31 characters. It would be nice if Excel returned an error if you try to assign an invalid name, but it doesn't appear to do so. Cheers, -Jan From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: August 10, 2007 10:30 AM To: perl-win32-users@listserv.ActiveState.com Subject: win32::ole (excel) question Hi all, Weird situation with creating new worksheets and keeping the title in the tab. I f I create just one everything is fine - when I add a second worksheet to the workbook the title goes away from the original worksheet. Code excerpt: This is where the object is instanciated and the first worksheet is created and named: #--create and open the first worksheet my $excel = Win32::OLE-new(Excel.Application); $excel-{Visible} = 1; my $book = $excel-Workbooks-Add; my $sheet = $book-Worksheets(1); $sheet-{Name} = Daily Message Volume By Queue Manager; **cells are filled in and formatted - everything looks great to this point Here'e where the next worksheet is added: #--create and open the second worksheet $sheet = $book-Worksheets-Add; $sheet-{Name} = Daily Message Volume By Queue; $sheet-Columns-{ColumnWidth} = 24; **When this worksheet is created the first worksheet goes back to being named Sheet1 Any thoughts greatly appreciated. Thanks in advance. Dave Kazatsky Senior Middleware Engineer NSE - Solutions Engineering W. (732) 893-4351 C. (973) 865-8106 The information contained in this message may be CONFIDENTIAL and is for the intended addressee only. Any unauthorized use, dissemination of the information, or copying of this message is prohibited. If you are not the intended addressee, please notify the sender immediately and delete this message. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE - filtering out ms word formatting characters
I guess these will just be CR/NL characters. You should be able to strip them in Perl, e.g. with $wordcell = $tbl-Cell($row,$col)-Range-{Text}; $wordcell =~ s/[\x00-\x1f]//g; $sheet-Cells($row,$col)-{Value} = $wordcell; Cheers, -Jan From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of jagdish eashwar Sent: May 11, 2007 6:13 PM To: perl-win32-users@listserv.activestate.com Subject: Win32::OLE - filtering out ms word formatting characters Hi, I am attempting to transfer data from a word table to Excel using Win32::OLE. I am able to do it with the following piece of code, but I am getting two little boxes after the text in each of the Excel cells. I presume these are Word formatting characters. How can I filter these out? I am using a test Word table of 5 rows and 5 columns. I have come across suggestions that one should save the Word file as an html file first. I did that and ran the program again after changing the input file name to tesfile.mht, but I am getting the same results. Perhaps I have to use some other module like HTML::PARSER. Isn't there some way I can do the filtering through Win32::OLE itself? use warnings; use strict; # INVOKE WIN32::OLE AND OPEN WORD AND EXCEL FILES # my($Word,$wordfile,$doc,$tbl,$wordcell); my($Excel,$excelfile,$book,$sheet,$excelcell); my($row,$col); use Win32::OLE qw(in with); use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Const 'Microsoft Word'; use Win32::OLE::Const 'Microsoft Office'; $Win32::OLE::Warn = 3; # Die on Errors. $wordfile = 'E:/jag/word_perl/testfile.doc'; $Word = Win32::OLE-GetActiveObject('Word.Application') || Win32::OLE-new('Word.Application', 'Quit'); $doc = $Word-Documents-Open($wordfile); $tbl = $doc-Tables(1); $excelfile = 'E:/jag/word_perl/testfile.xls'; $Excel = Win32::OLE-GetActiveObject('Excel.Application') || Win32::OLE-new('Excel.Application ', 'Quit'); $book = $Excel-Workbooks-Open($excelfile); $sheet = $book-Worksheets(Sheet1); # TRANSFER DATA #== foreach $row(1..5) { foreach $col(1..5) { $wordcell = $tbl-Cell($row,$col)-Range-{Text}; $sheet-Cells($row,$col)-{Value} = $wordcell; } } $doc-Save; $doc-Close; $book-Save; $book-Close; ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE - ? encoding of returned strings
When Win32::OLE uses CP_UTF8, then it will convert the UCS2 as returned from COM (the BSTR datatype) into UTF-8. There should be no loss of information in this step, as everything in UCS2 can also be represented in UTF8. The conversion is done by a Windows API and not by Perl internals. Win32::OLE then asks Perl to downgrade to a non-UTF-8 string if possible, because a lot of modules don't handle UTF-8 strings correctly. This step is error-prone, as Perl always assumes that byte strings are Latin-1 encoded and does not take the Windows code page into account. If *all* characters in the returned string are in Latin-1 and your Windows codepage is *not* 1252, then you may get distorted results. I guess I should put some support into Win32::OLE to force it to leave the string in UTF8. But I think this should be done in the wider context of teaching Perl to deal with Windows code pages better. Cheers, -Jan From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Trotman Sent: April 29, 2007 2:36 PM To: perl-win32-users@listserv.ActiveState.com Subject: Re: Win32::OLE - ? encoding of returned strings Thanks - that's very useful. And I had missed the Unicode mode in the Win32::OLE documentation. To clarify: Part of my problem is that the MSXML XSLT transformations do NOT output the character encoding in the XML declaration. So - $xmldoc-transformNode($xsltsheet) may output Windows-1252 encoded data - but does not contain encoding='Windows-1252' in the !? xml version='1.0'? and so other parts of the process expect it to contain UTF-8. If I turn on the Win32::OLE UTF8 code page for a Win32::OLE call to MSXML that returns a UTF-16 string (or Windows-1252) - is the automatic conversion to UTF8 likely to be correct - or incorrect? IE - does the automatic conversion correctly detect the CP of the OLE output? Thanks Jan Dubois wrote: On Fri, 27 Apr 2007, Mike Trotman wrote: I am writing a CGI application that uses WIN32::OLE to interface to Microsoft ADO, MS Access, SQL Server and MSXML for XML documents and XSLT transformations. I suspect that something in the way I am passing data around (or in the ADO implementation of 'savetoxml') is not dealing correctly with XML document encoding declarations. The data is originally in an MS Access database - but has been entered using copy and paste from MS Word documents from around the world - so contains many weird and wonderful bytes. To help in my debugging process can anyone tell me how WIN32::OLE deals with 'strings' returned from method calls? i.e. - are they pure byte data as output by the method (and maybe in UTF-16)? - or are they converted to Perl's internal format (using any current Perl encoding settings)? - or does something else happen? The problems I am having are primarily when outputting XML documents (or HTML) to send to the browser. e.g.my $OUTPUT=; $OUTPUT=$xmldoc-transformNode($xsltsheet); print $OUTPUT; All string data is converted to the current system codepage by Win32::OLE before being passed back to Perl _unless_ you switch Win32::OLE to Unicode mode first: Win32::OLE-Option(CP = Win32::OLE::CP_UTF8()); After this call all strings are converted to UTF8 and marked as such in the Perl internal flags. Cheers, -Jan Message Scanned by ClamAV on datalucid.com -- Datalucid Limited 8 Eileen Road South Norwood London SE25 5EJ tel :+44-0208-239-6810 email: [EMAIL PROTECTED] web: http://www.datalucid.com Message Scanned by ClamAV on datalucid.com ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE - ? encoding of returned strings
Thanks Jan - that's very clear and exactly what I needed to know. I've got most of my conversions working - but there are a few exceptions and I think your explanation has given me enough information to track then down and handle them. (I'm not using the Win32::OLE UTF8 forcing - and am getting some spurious character conversions.) Mike Jan Dubois wrote: When Win32::OLE uses CP_UTF8, then it will convert the UCS2 as returned from COM (the BSTR datatype) into UTF-8. There should be no loss of information in this step, as everything in UCS2 can also be represented in UTF8. The conversion is done by a Windows API and not by Perl internals. Win32::OLE then asks Perl to downgrade to a non-UTF-8 string if possible, because a lot of modules dont handle UTF-8 strings correctly. This step is error-prone, as Perl always assumes that byte strings are Latin-1 encoded and does not take the Windows code page into account. If *all* characters in the returned string are in Latin-1 and your Windows codepage is *not* 1252, then you may get distorted results. I guess I should put some support into Win32::OLE to force it to leave the string in UTF8. But I think this should be done in the wider context of teaching Perl to deal with Windows code pages better. Cheers, -Jan From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Mike Trotman Sent: April 29, 2007 2:36 PM To: perl-win32-users@listserv.ActiveState.com Subject: Re: Win32::OLE - ? encoding of returned strings Thanks - that's very useful. And I had missed the Unicode mode in the Win32::OLE documentation. To clarify: Part of my problem is that the MSXML XSLT transformations do NOT output the character encoding in the XML declaration. So - $xmldoc-transformNode($xsltsheet) may output Windows-1252 encoded data - but does not contain encoding='Windows-1252' in the !? xml version='1.0'? and so other parts of the process expect it to contain UTF-8. If I turn on the Win32::OLE UTF8 code page for a Win32::OLE call to MSXML that returns a UTF-16 string (or Windows-1252) - is the automatic conversion to UTF8 likely to be correct - or incorrect? IE - does the automatic conversion correctly detect the CP of the OLE output? Thanks Jan Dubois wrote: On Fri, 27 Apr 2007, Mike Trotman wrote: I am writing a CGI application that uses WIN32::OLE to interface to Microsoft ADO, MS Access, SQL Server and MSXML for XML documents and XSLT transformations. I suspect that something in the way I am passing data around (or in the ADO implementation of 'savetoxml') is not dealing correctly with XML document encoding declarations. The data is originally in an MS Access database - but has been entered using copy and paste from MS Word documents from around the world - so contains many weird and wonderful bytes. To help in my debugging process can anyone tell me how WIN32::OLE deals with 'strings' returned from method calls? i.e. - are they pure byte data as output by the method (and maybe in UTF-16)? - or are they converted to Perl's internal format (using any current Perl encoding settings)? - or does something else happen? The problems I am having are primarily when outputting XML documents (or HTML) to send to the browser. e.g.my $OUTPUT=""; $OUTPUT=$xmldoc-transformNode($xsltsheet); print $OUTPUT; All string data is converted to the current system codepage by Win32::OLE before being passed back to Perl _unless_ you switch Win32::OLE to Unicode mode first: Win32::OLE-Option(CP = Win32::OLE::CP_UTF8()); After this call all strings are converted to UTF8 and marked as such in the Perl internal flags. Cheers, -Jan Message Scanned by ClamAV on datalucid.com -- Datalucid Limited 8 Eileen Road South Norwood London SE25 5EJ tel :+44-0208-239-6810 email: [EMAIL PROTECTED] web: http://www.datalucid.com Message Scanned by ClamAV on datalucid.com -- Datalucid Limited 8 Eileen Road South Norwood London SE25 5EJ tel :+44-0208-239-6810 email: [EMAIL PROTECTED] web: http://www.datalucid.com Message Scanned by ClamAV on datalucid.com ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE - ? encoding of returned strings
Thanks - that's very useful. And I had missed the Unicode mode in the Win32::OLE documentation. To clarify: Part of my problem is that the MSXML XSLT transformations do NOT output the character encoding in the XML declaration. So - $xmldoc-transformNode($xsltsheet) may output Windows-1252 encoded data - but does not contain encoding='Windows-1252' in the !? xml version='1.0'? and so other parts of the process expect it to contain UTF-8. If I turn on the Win32::OLE UTF8 code page for a Win32::OLE call to MSXML that returns a UTF-16 string (or Windows-1252) - is the automatic conversion to UTF8 likely to be correct - or incorrect? IE - does the automatic conversion correctly detect the CP of the OLE output? Thanks Jan Dubois wrote: On Fri, 27 Apr 2007, Mike Trotman wrote: I am writing a CGI application that uses WIN32::OLE to interface to Microsoft ADO, MS Access, SQL Server and MSXML for XML documents and XSLT transformations. I suspect that something in the way I am passing data around (or in the ADO implementation of 'savetoxml') is not dealing correctly with XML document encoding declarations. The data is originally in an MS Access database - but has been entered using copy and paste from MS Word documents from around the world - so contains many weird and wonderful bytes. To help in my debugging process can anyone tell me how WIN32::OLE deals with 'strings' returned from method calls? i.e. - are they pure byte data as output by the method (and maybe in UTF-16)? - or are they converted to Perl's internal format (using any current Perl encoding settings)? - or does something else happen? The problems I am having are primarily when outputting XML documents (or HTML) to send to the browser. e.g.my $OUTPUT=""; $OUTPUT=$xmldoc-transformNode($xsltsheet); print $OUTPUT; All string data is converted to the current system codepage by Win32::OLE before being passed back to Perl _unless_ you switch Win32::OLE to Unicode mode first: Win32::OLE-Option(CP = Win32::OLE::CP_UTF8()); After this call all strings are converted to UTF8 and marked as such in the Perl internal flags. Cheers, -Jan Message Scanned by ClamAV on datalucid.com -- Datalucid Limited 8 Eileen Road South Norwood London SE25 5EJ tel :+44-0208-239-6810 email: [EMAIL PROTECTED] web: http://www.datalucid.com Message Scanned by ClamAV on datalucid.com ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE - ? encoding of returned strings
Thanks Jan, your recent tip on converting Win32::OLE-passed strings as UTF8 saved me hours of blank looks. Specifically: Win32::OLE-Option(CP = Win32::OLE::CP_UTF8()); Have a great Labour Day! Mike Trotman wrote: Thanks - that's very useful. And I had missed the Unicode mode in the Win32::OLE documentation. To clarify: Part of my problem is that the MSXML XSLT transformations do NOT output the character encoding in the XML declaration. So - $xmldoc-transformNode($xsltsheet) may output Windows-1252 encoded data - but does not contain encoding='Windows-1252' in the !? xml version='1.0'? and so other parts of the process expect it to contain UTF-8. If I turn on the Win32::OLE UTF8 code page for a Win32::OLE call to MSXML that returns a UTF-16 string (or Windows-1252) - is the automatic conversion to UTF8 likely to be correct - or incorrect? IE - does the automatic conversion correctly detect the CP of the OLE output? Thanks Jan Dubois wrote: On Fri, 27 Apr 2007, Mike Trotman wrote: I am writing a CGI application that uses WIN32::OLE to interface to Microsoft ADO, MS Access, SQL Server and MSXML for XML documents and XSLT transformations. I suspect that something in the way I am passing data around (or in the ADO implementation of 'savetoxml') is not dealing correctly with XML document encoding declarations. The data is originally in an MS Access database - but has been entered using copy and paste from MS Word documents from around the world - so contains many weird and wonderful bytes. To help in my debugging process can anyone tell me how WIN32::OLE deals with 'strings' returned from method calls? i.e. - are they pure byte data as output by the method (and maybe in UTF-16)? - or are they converted to Perl's internal format (using any current Perl encoding settings)? - or does something else happen? The problems I am having are primarily when outputting XML documents (or HTML) to send to the browser. e.g.my $OUTPUT=; $OUTPUT=$xmldoc-transformNode($xsltsheet); print $OUTPUT; All string data is converted to the current system codepage by Win32::OLE before being passed back to Perl _unless_ you switch Win32::OLE to Unicode mode first: Win32::OLE-Option(CP = Win32::OLE::CP_UTF8()); After this call all strings are converted to UTF8 and marked as such in the Perl internal flags. Cheers, -Jan Message Scanned by ClamAV on datalucid.com -- Datalucid Limited 8 Eileen Road South Norwood London SE25 5EJ tel :+44-0208-239-6810 email: [EMAIL PROTECTED] web: http://www.datalucid.com Message Scanned by ClamAV on datalucid.com ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE - ? encoding of returned strings
On Fri, 27 Apr 2007, Mike Trotman wrote: I am writing a CGI application that uses WIN32::OLE to interface to Microsoft ADO, MS Access, SQL Server and MSXML for XML documents and XSLT transformations. I suspect that something in the way I am passing data around (or in the ADO implementation of 'savetoxml') is not dealing correctly with XML document encoding declarations. The data is originally in an MS Access database - but has been entered using copy and paste from MS Word documents from around the world - so contains many weird and wonderful bytes. To help in my debugging process can anyone tell me how WIN32::OLE deals with 'strings' returned from method calls? i.e. - are they pure byte data as output by the method (and maybe in UTF-16)? - or are they converted to Perl's internal format (using any current Perl encoding settings)? - or does something else happen? The problems I am having are primarily when outputting XML documents (or HTML) to send to the browser. e.g.my $OUTPUT=; $OUTPUT=$xmldoc-transformNode($xsltsheet); print $OUTPUT; All string data is converted to the current system codepage by Win32::OLE before being passed back to Perl _unless_ you switch Win32::OLE to Unicode mode first: Win32::OLE-Option(CP = Win32::OLE::CP_UTF8()); After this call all strings are converted to UTF8 and marked as such in the Perl internal flags. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: win32::ole can't call method select on an undefined value
Hi, I don't know if this is of much help, but your code is working for me after I include the usual incantations for loading WIN32::OLE at the top. jagdish eashwar ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE threads
On Fri, 12 May 2006, ? wrote: I have the latest - 5.8.8.817 - perl installed on my Win2000 SP4. Running this script use threads; use Win32::OLE; threads-new( sub {print oops, i did it again\n} )-join; __END__ crushes perl interpreter after execution with the following message: Free to wrong pool 1a43338 not 15d2cf0 during global destruction. There is no issue as soon as 'use Win32::OLE;' is #ed OR no join() or detach() is called on a thread. I'm sure there are folks who ran into this before. Any explanations? Yes, Win32::OLE is still not compatible with either fork() emulation nor the threads module. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32-OLE crash
Please try your program with ActivePerl build 817. I fixed a bug in Win32::OLE that would cause crashes in IE events, so this may be the same thing. Please confirm if the problem is gone in 817, or if it still happens. Cheers, -Jan PS: Please use plain text instead of HTML for mailing list posts! ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE::Variant, perl crashing.
Thanks Luke, SUPER. That's the one I was thinking about. Much better than nesting every last single call to Date() in an ungainly if/else statement. - Original Message - From: Luke Bakken [EMAIL PROTECTED] To: perl-win32-users@listserv.ActiveState.com Subject: Re: Win32::OLE::Variant, perl crashing. Date: Sat, 6 May 2006 14:34:35 -0700 if (ref ($sentdate) eq 'Win32::OLE::Variant') { # something with $sentdate-Date } else { # assume $sentdate is a string. } Best practice is to use UNIVERSAL::isa() : if (UNIVERSAL::isa($sentdate, 'Win32::OLE::Variant')) { } else { } Tested with: perl -MWin32::OLE::Variant -e$v=Win32::OLE::Variant-new();print qq(YESSIR) if UNIVERSAL::isa($v, q(Win32::OLE::Variant)) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs -- ___ Search for businesses by name, location, or phone number. -Lycos Yellow Pages http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE::Variant, perl crashing.
Sure. if (ref ($sentdate) eq 'Win32::OLE::Variant') { # something with $sentdate-Date } else { # assume $sentdate is a string. } There might be something more efficient one can do with SUPER or AUTOLOAD or something. I've never had the time to figure it out though. - Original Message - From: Satish Kaushik [EMAIL PROTECTED] To: perl-win32-users@listserv.ActiveState.com Subject: Win32::OLE::Variant, perl crashing. Date: Fri, 5 May 2006 12:24:17 -0700 Hi Everyone, I am using this module for the dates. While testing I came acorss one date which was not a Variant, PERL died saying can't call 'Date' method . I tried to get the 'Type' from the string but again since given string is not a Variant, it crashed. Is there any way to identify whether date is a Variant or a simple String? I would be really thankful if anyone suggests some thing, Thanks Regards Satish ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs -- ___ Search for businesses by name, location, or phone number. -Lycos Yellow Pages http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE::Variant, perl crashing.
if (ref ($sentdate) eq 'Win32::OLE::Variant') { # something with $sentdate-Date } else { # assume $sentdate is a string. } Best practice is to use UNIVERSAL::isa() : if (UNIVERSAL::isa($sentdate, 'Win32::OLE::Variant')) { } else { } Tested with: perl -MWin32::OLE::Variant -e$v=Win32::OLE::Variant-new();print qq(YESSIR) if UNIVERSAL::isa($v, q(Win32::OLE::Variant)) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE::Variant, perl crashing.
Title: Win32::OLE::Variant, perl crashing. Not sure off the top of my head. Is there any way you could post some example code? From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Satish Kaushik Sent: Friday, May 05, 2006 12:24 PM To: perl-win32-users@listserv.ActiveState.com Subject: Win32::OLE::Variant, perl crashing. Hi Everyone, I am using this module for the dates. While testing I came acorss one date which was not a Variant, PERL died saying can't call 'Date' method . I tried to get the 'Type' from the string but again since given string is not a Variant, it crashed. Is there any way to identify whether date is a Variant or a simple String? I would be really thankful if anyone suggests some thing, Thanks Regards Satish ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE::Variant, perl crashing.
Title: Win32::OLE::Variant, perl crashing. Hi Timothy, Thanks for your response. This is a subroutine, where I am getting this problem while accessing Date method. sub process_date_variant{my $inputvar =shift; my $sentvariant = Variant(VT_DATE,'Jan 1, 1970 3:00 pm');my($convertdate, $sentdate); $sentvariant = $inputvar;$senton ='Thu, 01 Jan 1970 00:00:00 GMT'; #default date if($sentvariant ($sentvariant =~m/[0-9]+/)){$sentdate = $sentvariant-Date(LOCALE_NOUSEROVERRIDE|DATE_SHORTDATE)." ".$sentvariant-Time(TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER)." "."GMT";}else{undef $sentdate;}return $sentdate; } Regards Satish From: Timothy Johnson [mailto:[EMAIL PROTECTED] Sent: Friday, May 05, 2006 2:23 PMTo: [EMAIL PROTECTED]; perl-win32-users@listserv.ActiveState.comSubject: RE: Win32::OLE::Variant, perl crashing. Not sure off the top of my head. Is there any way you could post some example code? From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Satish KaushikSent: Friday, May 05, 2006 12:24 PMTo: perl-win32-users@listserv.ActiveState.comSubject: Win32::OLE::Variant, perl crashing. Hi Everyone, I am using this module for the dates. While testing I came acorss one date which was not a Variant, PERL died saying can't call 'Date' method . I tried to get the 'Type' from the string but again since given string is not a Variant, it crashed. Is there any way to identify whether date is a Variant or a simple String? I would be really thankful if anyone suggests some thing, Thanks Regards Satish ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE - Mem Leak? (FIXED)
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Sobey Sent: 20 March 2006 11:50 To: perl-win32-users@listserv.ActiveState.com Subject: Win32::OLE - Mem Leak? I'm trying to debug a slow memory leak in a service I have written to monitor performance counters on my servers. The service queries several wmi every 5 seconds, and exhibits a very slow leak, such that processes grow to a 100MB in size after a few weeks. snip Thanks to the excellent Jan Dubois, who has not only confirmed the leak (in the Win32::OLE _in_ function), but also provided a workaround. Replacing: my $ResultSet = $WMI-ExecQuery($SQL); foreach my $result ( in $ResultSet) { foreach my $attribute ( @{ $wmi_queries-{$class} } ) { my $answer = $result-{$attribute}; } } with: my $result_count = $ResultSet-{count}; my $enum = Win32::OLE::Enum-new($ResultSet); # print Got $result_count items in set\n; for ( 1 .. $result_count ) { my $result = $enum-Next; foreach my $attribute ( @{ $wmi_queries-{$class} } ) { my $answer = $result-{$attribute}; } } ## end for ( 1 .. $result_count) fixes the problem, ie getting a count of attributes returned, and iterating across them explicitly with the Win32::OLE::Enum object's Next command. Fixed code attached, and works like a charm. Win32::OLE will hopefully be fixed in the release of libwin32. Thanks again Jan - you've saved my bacon. P. * Gloucester Research Limited believes the information provided herein is reliable. While every care has been taken to ensure accuracy, the information is furnished to the recipients with no warranty as to the completeness and accuracy of its contents and on condition that any errors or omissions shall not be made the basis for any claim, demand or cause for action. The information in this email is intended only for the named recipient. If you are not the intended recipient please notify us immediately and do not copy, distribute or take action based on this e-mail. Gloucester Research Limited, 5th Floor, Whittington House, 19-30 Alfred Place, London WC1E 7EA * wmi.pl Description: wmi.pl ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE and Acroread anybody?
Hi Lynn, I haven't personally done this- but I've had some luck with Win32::OLE. Try $acroApp = Win32::OLE-new(AcroExch.App); $acroDoc = Win32::OLE-new(AcroExch.PDDoc); HTH- KC On 1/16/06, Lynn. Rickards [EMAIL PROTECTED] wrote: Greetings,Wondering if anyone has had any success controlling Adobe Acroreader thru OLE. Thereappears to be limited functionality exposed, as seen in OLE browser, but I didn't getpast the first hurdle $acroApp = Win32::OLE-new('???');Any clue most welcome.TIA - Lynn.___Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.comTo unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE and Acroread anybody?
From: Kevin Carothers Hi Lynn, I haven't personally done this- but I've had some luck with Win32::OLE. Try $acroApp = Win32::OLE-new(AcroExch.App); $acroDoc = Win32::OLE-new(AcroExch.PDDoc); HTH- Thanks - though the first is indicated valid in acrord32.dll these and anything else I tried thus far, return Invalid class string I'm starting to think Adobe have crippled the Reader API. Maybe time to try working with SendKeys... :-( On 1/16/06, LYNN. RICKARDS [LINK: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Greetings, Wondering if anyone has had any success controlling Adobe Acroreader thru OLE. There appears to be limited functionality exposed, as seen in OLE browser, but I didn't get past the first hurdle $acroApp = Win32::OLE-new('???'); Any clue most welcome. TIA - Lynn. ___ Perl-Win32-Users mailing list [LINK: mailto:[EMAIL PROTECTED] Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: [LINK: http://listserv.ActiveState.com/mailman/mysubs] http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [LINK: [EMAIL PROTECTED] Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: [LINK: http://listserv.ActiveState.com/mailman/mysubs] http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE and Acroread anybody?
Kevin Carothers wrote: Hi Lynn, What specifically are you trying to automate? Maybe I can try and help you find something (no promises, tho :-) KC Thanks for the thought - the aim is to open a document and either navigate to a known page or run a search. Useful-looking methods look to be exposed, I thought... I just came across the Acrobat module under wxPerl/ActiveX which looks hopeful, unless you or anyone have alternative suggestions. [OT] Paper books are far superior to PDF - I can bookmark any page I choose, without having to pay extra for special paper with foldable corners... From: Kevin Carothers Hi Lynn, I haven't personally done this- but I've had some luck with Win32::OLE. Try $acroApp = Win32::OLE-new(AcroExch.App ); $acroDoc = Win32::OLE-new(AcroExch.PDDoc); HTH- Thanks - though the first is indicated valid in acrord32.dll these and anything else I tried thus far, return Invalid class string I'm starting to think Adobe have crippled the Reader API. Maybe time to try working with SendKeys... :-( On 1/16/06, LYNN. RICKARDS [LINK: mailto: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]] [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Greetings, Wondering if anyone has had any success controlling Adobe Acroreader thru OLE. There appears to be limited functionality exposed, as seen in OLE browser, but I didn't get past the first hurdle $acroApp = Win32::OLE-new('???'); Any clue most welcome. TIA - Lynn. ___ ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::Ole (MAPI) and Win2K scheduler
Christopher Taranto wrote: Hi Ken, Wednesday, January 4, 2006, 5:07:58 AM, you wrote: LK Thanks to Steven Manross, I'm a step further along in LK troubleshooting this. Using Steven's suggestion, I got the LK following from OLE-LastError: 'Win32::OLE(0.1403) error LK 0x80070005: Access is denied'. Does anyone out there know LK anything about how the Win2k scheduler accesses objects (and, more LK importantly, how to circumvent this problem)? As I stated LK earlier, the scheduled task is running under the same userid I use LK to log on when I successfully run my program at a command prompt. [% snip %] LK I created a program using ActiveState's perl 5.8.4, compiled it using LK perlapp 5.3.0 and ran it on Windows 2000 Professional SP4 against LK Outlook 2000 SR-1 (9.0.0.3821). It runs properly both from a command LK prompt and as a scheduled task. I released it into production on LK Windows 2000 server SP4 using the identical version of Outlook 2000. LK Again, it runs great from a command prompt. When I run it as a LK scheduled task, however, it dies because it's not able to get the LK Outlook Application. I also had problems on Win2k SP4 running Perl scripts via scheduler that had worked fine from the command prompt. I came to the conclusion that scheduler does not exactly simulate a dos command prompt and things like automatically invoking perl by the suffix .pl didn't work, and I suspect it doesn't use Path either. I had to set the start in value to give it a kickoff point. You could try playing with that. LK LK Here's the relevant code: LK LK LK Win32::OLE-Initialize(Win32::OLE::COINIT_OLEINITIALIZE); LK die Win32::OLE-LastError(),\n if Win32::OLE-LastError( ); LK eval { $Outlook = LK Win32::OLE-GetActiveObject('Outlook.Application') LK }; LK die Outlook is not installed if $@; LK unless (defined $Outlook) { LK $Outlook = Win32::OLE-new('Outlook.Application', sub {$_[0]-Quit;}); LK or die Oops, cannot start Outlook; LK === dies here under Win2k srvr as a scheduled task I'm not sure if this will help or solve your problem - but you could give Outlook Redemption a look - http://www.dimastr.com/redemption/ Outlook Redemption works around limitations imposed by the Outlook Security Patch and Service Pack 2 of MS Office 98/2000 and Office 2002 and 2003 (which include Security Patch) plus provides a number of objects and functions to work with properties and functionality not exposed through the Outlook object model. Good luck! -- - corporate disclaimer drivel goes here ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::Ole (MAPI) and Win2K scheduler
Thanks to Steven Manross, I'm a step further along in troubleshooting this. Using Steven's suggestion, I got the following from OLE-LastError: 'Win32::OLE(0.1403) error 0x80070005: Access is denied'. Does anyone out there know anything about how the Win2k scheduler accesses objects (and, more importantly, how to circumvent this problem)? As I stated earlier, the scheduled task is running under the same userid I use to log on when I successfully run my program at a command prompt. Ken -Original Message- From: Steven Manross [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 03, 2006 5:18 PM To: LeFevre, Ken; perl-win32-users@listserv.ActiveState.com Subject: RE: Win32::Ole (MAPI) and Win2K scheduler Replace : die Oops, cannot start Outlook; with open (FILE,c:\\outlookerror.txt); print FILE Oops, cannot start Outlook\n.Win32::OLE-LastError(); close (FILE); die Oops, cannot start Outlook; It will help refine what error the script is throwing (and refine the possible solutions to the problem). Steven From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of LeFevre, Ken Sent: Tuesday, January 03, 2006 1:01 PM To: perl-win32-users@listserv.ActiveState.com Subject: Win32::Ole (MAPI) and Win2K scheduler I created a program using ActiveState's perl 5.8.4, compiled it using perlapp 5.3.0 and ran it on Windows 2000 Professional SP4 against Outlook 2000 SR-1 (9.0.0.3821). It runs properly both from a command prompt and as a scheduled task. I released it into production on Windows 2000 server SP4 using the identical version of Outlook 2000. Again, it runs great from a command prompt. When I run it as a scheduled task, however, it dies because it's not able to get the Outlook Application. Here's the relevant code: Win32::OLE-Initialize(Win32::OLE::COINIT_OLEINITIALIZE); die Win32::OLE-LastError(),\n if Win32::OLE-LastError( ); eval { $Outlook = Win32::OLE-GetActiveObject('Outlook.Application') }; die Outlook is not installed if $@; unless (defined $Outlook) { $Outlook = Win32::OLE-new('Outlook.Application', sub {$_[0]-Quit;}); or die Oops, cannot start Outlook; === dies here under Win2k srvr as a scheduled task As best I can tell, Outlook is registered the same on both machines. The same dlls exist on both. I even set up the scheduled task to run under the same userid I used when logging on to the server to run the program from the command prompt. My theory is that there is some sort of permissions issue or a difference in the scheduled task environment between the two versions of the Win2k OS, but I'm not succeeded at finding the problem and how to resolve it. I would greatly appreciate any insight or assistance in getting this to run in the new environment. Thanks, Ken ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::Ole (MAPI) and Win2K scheduler
On 1/4/06, LeFevre, Ken wrote: Thanks to Steven Manross, I'm a step further along in troubleshooting this. Using Steven's suggestion, I got the following from OLE-LastError: 'Win32::OLE(0.1403) error 0x80070005: Access is denied'. Does anyone out there know anything about how the Win2k scheduler accesses objects (and, more importantly, how to circumvent this problem)? As I stated earlier, the scheduled task is running under the same userid I use to log on when I successfully run my program at a command prompt. Ken -Original Message- From: Steven Manross [] Sent: Tuesday, January 03, 2006 5:18 PM To: LeFevre, Ken; Subject: RE: Win32::Ole (MAPI) and Win2K scheduler Replace : die Oops, cannot start Outlook; with open (FILE,c:\\outlookerror.txt); print FILE Oops, cannot start Outlook\n.Win32::OLE-LastError(); close (FILE); die Oops, cannot start Outlook; It will help refine what error the script is throwing (and refine the possible solutions to the problem). Steven From: [mailto:] On Behalf Of LeFevre, Ken Sent: Tuesday, January 03, 2006 1:01 PM To: Subject: Win32::Ole (MAPI) and Win2K scheduler I created a program using ActiveState's perl 5.8.4, compiled it using perlapp 5.3.0 and ran it on Windows 2000 Professional SP4 against Outlook 2000 SR-1 (9.0.0.3821). It runs properly both from a command prompt and as a scheduled task. I released it into production on Windows 2000 server SP4 using the identical version of Outlook 2000. Again, it runs great from a command prompt. When I run it as a scheduled task, however, it dies because it's not able to get the Outlook Application. Here's the relevant code: Win32::OLE-Initialize(Win32::OLE::COINIT_OLEINITIALIZE); die Win32::OLE-LastError(),\n if Win32::OLE-LastError( ); eval { $Outlook = Win32::OLE-GetActiveObject('Outlook.Application') }; die Outlook is not installed if $@; unless (defined $Outlook) { $Outlook = Win32::OLE-new('Outlook.Application', sub {$_[0]-Quit;}); or die Oops, cannot start Outlook; === dies here under Win2k srvr as a scheduled task As best I can tell, Outlook is registered the same on both machines. The same dlls exist on both. I even set up the scheduled task to run under the same userid I used when logging on to the server to run the program from the command prompt. My theory is that there is some sort of permissions issue or a difference in the scheduled task environment between the two versions of the Win2k OS, but I'm not succeeded at finding the problem and how to resolve it. I would greatly appreciate any insight or assistance in getting this to run in the new environment. Thanks, Ken ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Try going into Administrative Tools = Local Security Settings = User Rights Assignment and experiment with the 'Log on as a batch job' and 'Log on as a service' settings. -Jason ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::Ole (MAPI) and Win2K scheduler
Replace : die Oops, cannot start Outlook; with open (FILE,c:\\outlookerror.txt); print FILE Oops, cannot start Outlook\n.Win32::OLE-LastError(); close (FILE); die Oops, cannot start Outlook; It will help refine what error the script is throwing (and refine the possible solutions to the problem). Steven From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of LeFevre, Ken Sent: Tuesday, January 03, 2006 1:01 PM To: perl-win32-users@listserv.ActiveState.com Subject: Win32::Ole (MAPI) and Win2K scheduler I created a program using ActiveState's perl 5.8.4, compiled it using perlapp 5.3.0 and ran it on Windows 2000 Professional SP4 against Outlook 2000 SR-1 (9.0.0.3821). It runs properly both from a command prompt and as a scheduled task. I released it into production on Windows 2000 server SP4 using the identical version of Outlook 2000. Again, it runs great from a command prompt. When I run it as a scheduled task, however, it dies because it's not able to get the Outlook Application. Here's the relevant code: Win32::OLE-Initialize(Win32::OLE::COINIT_OLEINITIALIZE); die Win32::OLE-LastError(),\n if Win32::OLE-LastError( ); eval { $Outlook = Win32::OLE-GetActiveObject('Outlook.Application') }; die Outlook is not installed if $@; unless (defined $Outlook) { $Outlook = Win32::OLE-new('Outlook.Application', sub {$_[0]-Quit;}); or die Oops, cannot start Outlook; === dies here under Win2k srvr as a scheduled task As best I can tell, Outlook is registered the same on both machines. The same dlls exist on both. I even set up the scheduled task to run under the same userid I used when logging on to the server to run the program from the command prompt. My theory is that there is some sort of permissions issue or a difference in the scheduled task environment between the two versions of the Win2k OS, but I'm not succeeded at finding the problem and how to resolve it. I would greatly appreciate any insight or assistance in getting this to run in the new environment. Thanks, Ken ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::Ole (MAPI) and Win2K scheduler
LeFevre, Ken wrote: I created a program using ActiveState's perl 5.8.4, compiled it using perlapp 5.3.0 and ran it on Windows 2000 Professional SP4 against Outlook 2000 SR-1 (9.0.0.3821). It runs properly both from a command prompt and as a scheduled task. I released it into production on Windows 2000 server SP4 using the identical version of Outlook 2000. Again, it runs great from a command prompt. When I run it as a scheduled task, however, it dies because it's not able to get the Outlook Application. Hi there, I'm afraid I have no solution to your problem, but if you've found help, please share with me, as I code to access Outlook as well. One of the (unrelated) Outlook issues that I deal with, is that with the latest Outlook, the user is prompted to grant access to the Perl application, when the application starts. Some kind of security measure on Microsoft's part, but it does not happen for Outlook 2000. Here's the relevant code: Win32::OLE-Initialize(Win32::OLE::COINIT_OLEINITIALIZE); die Win32::OLE-LastError(),\n if Win32::OLE-LastError( ); eval { $Outlook = Win32::OLE-GetActiveObject('Outlook.Application') }; die Outlook is not installed if $@; unless (defined $Outlook) { $Outlook = Win32::OLE-new('Outlook.Application', sub {$_[0]-Quit;}); or die Oops, cannot start Outlook; === dies here under Win2k srvr as a scheduled task As best I can tell, Outlook is registered the same on both machines. The same dlls exist on both. I even set up the scheduled task to run under the same userid I used when logging on to the server to run the program from the command prompt. My theory is that there is some sort of permissions issue or a difference in the scheduled task environment between the two versions of the Win2k OS, but I'm not succeeded at finding the problem and how to resolve it. I would greatly appreciate any insight or assistance in getting this to run in the new environment. Thanks, Ken ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::Ole (MAPI) and Win2K scheduler
You can get around this popup box in Outlook XP with this fix Actually it's a security setting that says that x user is allowed to run programatically.. You'll need Exchange Admin rights to install it in a Public Folder. So, this may or may not help you. It's actually a security risk to enable this, but so is running an old Outlook release, so choose your poison.. http://support.microsoft.com/default.aspx?scid=kb;EN-US;290499 http://office.microsoft.com/en-us/assistance/HA011362851033.aspx http://download.microsoft.com/download/OfficeXPProf/Install/5.0.2920.0.1 /W98NT42KMe/EN-US/ADMPACK.EXE I set it up once so I could help again if needed, but it's been a long long time.. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Foo Ji-Haw Sent: Tuesday, January 03, 2006 7:46 PM To: LeFevre, Ken Cc: perl-win32-users@listserv.ActiveState.com Subject: Re: Win32::Ole (MAPI) and Win2K scheduler LeFevre, Ken wrote: I created a program using ActiveState's perl 5.8.4, compiled it using perlapp 5.3.0 and ran it on Windows 2000 Professional SP4 against Outlook 2000 SR-1 (9.0.0.3821). It runs properly both from a command prompt and as a scheduled task. I released it into production on Windows 2000 server SP4 using the identical version of Outlook 2000. Again, it runs great from a command prompt. When I run it as a scheduled task, however, it dies because it's not able to get the Outlook Application. Hi there, I'm afraid I have no solution to your problem, but if you've found help, please share with me, as I code to access Outlook as well. One of the (unrelated) Outlook issues that I deal with, is that with the latest Outlook, the user is prompted to grant access to the Perl application, when the application starts. Some kind of security measure on Microsoft's part, but it does not happen for Outlook 2000. Here's the relevant code: Win32::OLE-Initialize(Win32::OLE::COINIT_OLEINITIALIZE); die Win32::OLE-LastError(),\n if Win32::OLE-LastError( ); eval { $Outlook = Win32::OLE-GetActiveObject('Outlook.Application') }; die Outlook is not installed if $@; unless (defined $Outlook) { $Outlook = Win32::OLE-new('Outlook.Application', sub {$_[0]-Quit;}); or die Oops, cannot start Outlook; === dies here under Win2k srvr as a scheduled task As best I can tell, Outlook is registered the same on both machines. The same dlls exist on both. I even set up the scheduled task to run under the same userid I used when logging on to the server to run the program from the command prompt. My theory is that there is some sort of permissions issue or a difference in the scheduled task environment between the two versions of the Win2k OS, but I'm not succeeded at finding the problem and how to resolve it. I would greatly appreciate any insight or assistance in getting this to run in the new environment. Thanks, Ken --- - ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE to write macro to Excel workbook?
On Fri, 30 Dec 2005, Lynn. Rickards wrote: Thanks - that's a whole lot of steps in the right direction, but brings up the question what is perlCOM? I have the PDK but no sign there, and all the refs seem to indicate that is where it should be. PerlCOM used to be part of the PDK but has been removed in PDK 5, I think. It was never ported to Perl 5.8. You can create a control yourself with PerlCtrl that does most everything that PerlCOM did. Set PerlCOM = CreateObject(PerlCOM.Script) throws an activex error, cannot create object. The few other perl references I found, indicate this should work? The PerlCOM part should be irrelevant to your current problem. It is used in the sample to call from VBA into Perl. I understand you just want to add a VBA script to an Excel spreadsheet, but the VBA code doesn't need to execute arbitrary Perl code. The sample did show how to use the VBA object model to add a code component. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE to write macro to Excel workbook?
Jan Dubois wrote: On Fri, 30 Dec 2005, Lynn. Rickards wrote: Thanks - that's a whole lot of steps in the right direction, but brings up the question what is perlCOM? I have the PDK but no sign there, and all the refs seem to indicate that is where it should be. PerlCOM used to be part of the PDK but has been removed in PDK 5, I think. It was never ported to Perl 5.8. You can create a control yourself with PerlCtrl that does most everything that PerlCOM did. Aha! ummm...any docs on this aspect of perlctrl in particular? Set PerlCOM = CreateObject(PerlCOM.Script) throws an activex error, cannot create object. The few other perl references I found, indicate this should work? The PerlCOM part should be irrelevant to your current problem. It is used in the sample to call from VBA into Perl. I understand you just want to add a VBA script to an Excel spreadsheet, but the VBA code doesn't need to execute arbitrary Perl code. The sample did show how to use the VBA object model to add a code component. Agreed...and I'm slowly getting where I want to be thanks to the example. The perlCOM just looked like a really neat-o way to replace VB with perl. Don't I recall a recent unsolved thread on that question? - Lynn. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE to write macro to Excel workbook?
On Thu, 29 Dec 2005, Lyndon Rickards wrote: I'm looking to add some controls to a workbook, not possible using Spreadsheet::WriteExcel, with which I create the workbook. Advice, pointers anyone? Specifically Activate and deActivate routines to be written to ThisWorkbook and each of it's worksheets. Recording a macro adding code, just gives an empty sub :-( I once wrote some code to add a macro to the normal.dot template in Word. I assume the code for Excel is pretty similar, given that both use VBA to manage the macros. I remember that it took a lot of trial and error to figure out how to use the VBA object model as not everything works as you would expect it to work. Anyways, here is the code from a talk I gave at The Perl Conference 3 in 1999 (link will probably get wrapped): http://opensource.activestate.com/authors/jandubois/Perl/TPC3/fun.html#Using_PerlCOM_Babelfish_for_Mic If you manage to get it to work with contemporary versions of Excel, please post some working code back to the mailing list. :) Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE, ADODB.Stream and ADODB.Command problem.
Try this... $cmCmd-Properties('Output stream')-{'Value'} = $sResponseStream; I can't test it but I think that's the correct invocation. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Luke Bakken Sent: Monday, October 10, 2005 2:25 PM To: perl-win32-users@listserv.ActiveState.com; beginners@perl.org Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Win32::OLE, ADODB.Stream and ADODB.Command problem. Hello all, I'm trying to use Win32::OLE (version 0.1703) and the ADODB objects to retrieve XML being produced by a stored procedure on SQL server. I used the following code as a guide: http://msdn.microsoft.com/library/en-us/dnsqlmag2k/html/adoxmlListing_02 .txt If I create a VB project using the above code as a reference I can get the data out of the server without any problems. I can also retrieve the data with the osql program. However, the following perl code gives me this error: Error is -- OLE exception from ADODB.Command: Object or provider is not capable of performing requested operation. Win32::OLE(0.1703) error 0x800a0cb3 in METHOD/PROPERTYGET Execute -- in file Z:\XXI\Core\Install\SQL\DBcreate\test_xml.plx, package main, line 36 --- use strict; use Win32::OLE qw/in with/; use Win32::OLE::Const 'Microsoft ActiveX Data Objects 2.8 Library'; ++$|; my $connStr = q{Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Globalfs;Data Source=GFSDBmaster;Use Procedure for Prepare=0;Connect Timeout=4;Trusted_Connection=Yes}; my $cnConn = Win32::OLE-new('ADODB.Connection'); $cnConn-Open($connStr); chkW32LastErr(); my $cmCmd = Win32::OLE-new('ADODB.Command'); with($cmCmd, 'ActiveConnection' = $cnConn, 'CommandType' = adCmdStoredProc, 'CommandText' = 'dbo.report_a_table_with_XML' ); $cmCmd-Parameters-Append($cmCmd-CreateParameter('@table_name', adVarChar, adParamInput, 64, 'Branch')); $cmCmd-Parameters-Append($cmCmd-CreateParameter('@show_check_constrai nts', adTinyInt, adParamInput, 1, 1)); $cmCmd-Parameters-Append($cmCmd-CreateParameter('@style_sheet', adVarChar, adParamInput, 64, 'TableDump.xsl')); for my $param (in $cmCmd-Parameters) { print Param: , $param-Name, Value: , $param-Value, \n; } # Create a stream to handle the response my $sResponseStream = Win32::OLE-new('ADODB.Stream'); $sResponseStream-Open(); $cmCmd-{'Properties'}-{'Output stream'}-{'Value'} = $sResponseStream; $cmCmd-Execute({ 'Options' = adExecuteStream }); chkW32LastErr(); print $sResponseStream-ReadText(); sub chkW32LastErr { my $warnonly = shift; my $lastError = Win32::OLE-LastError(); if ($lastError) { my ($package, $filename, $line) = caller(); unless ($warnonly) { die qq{Error is\n--\n$lastError\n--\nin file $filename, package $package, line $line\n}; } else { print STDERR qq{Warning is\n--\n$lastError\n--\nin file $filename, package $package, line $line\n}; } } return $lastError; } --- I believe the following line is not assigning the $sResponseStream object to the Output stream property: $cmCmd-{'Properties'}-{'Output stream'}-{'Value'} = $sResponseStream; If I check the value of the Output stream property after the assignment with Win32::OLE-QueryObjectType() it indicates that it is not a valid Win32::OLE object. Am I doing the assignment incorrectly? I can't imagine this being a limitation of Win32::OLE. Thanks, Luke ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE(0.1701) error 0x80005000 when adding a computer to AD using Perl
Ken Cornetet helped me find the solution: * Use plain-text authentication, which fixed the issue. -Original Message- From: Steven Manross [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 05, 2005 12:47 AM To: Zeltov Alex; perl-win32-users@listserv.ActiveState.com Subject: RE: Win32::OLE(0.1701) error 0x80005000 when adding a computer to AD using Perl Hmmm.. I think this is a permissions delegation issue.. Is the IIS Server trusted for delegation? This is of course a security risk... But so is opening IE.. :) Steven From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Zeltov Alex Sent: Tuesday, September 20, 2005 1:06 PM To: perl-win32-users@listserv.ActiveState.com Subject: Win32::OLE(0.1701) error 0x80005000 when adding a computer to AD using Perl I am running into a problem, when I execute a simple script to add a computer to an AD when I do it through a cgi script. This is the code that I am running: my $strBase = OU=iLab - iLab Gatekeeper,OU=InfrApps - Infrastructure Managed Apps,OU=Applications,OU=US-DC1,DC=resdm50,DC=ilab,DC=siemensmedasp,DC=co m; my $strComp = alex; # e.g. joe-xp my $strDescr = none; # e.g. Joe's Windows XP workstation use Win32::OLE; $Win32::OLE::Warn = 3; # $ADS_USER_FLAG_ENUM my $ADS_UF_WORKSTATION_TRUST_ACCOUNT = 0x1000; my $objCont = Win32::OLE-GetObject(LDAP:// . $strBase); my $objComp = $objCont-Create(computer, cn= . $strComp); $objComp-Put(sAMAccountName, $strComp . \$); #$objComp-Put(description, $strDesc); $objComp-Put(userAccountControl, $ADS_UF_WORKSTATION_TRUST_ACCOUNT); $objComp-SetInfo; This code works fine when I run it as a stand alone program. When it runs under IIS, as cgi I am running into this error: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: Win32::OLE(0.1701) error 0x80005000 after character 0 in LDAP://OU=US-DC1,DC=resdm50,DC=ilab,DC=siemensmedasp,DC=com at F:\ttx218\dev\joincomputer.pl line 22 eval {...} called at F:\ttx218\dev\joincomputer.pl line 22 I have integrated windows authentication enabled, so the script runs under the same security permissions when i run it as IIS or as stand alone. Has anyone encountered this issue? I have googled this error and found a couple of threads having similar issue http://lists.ee.ethz.ch/realmen/msg00035.html Unfortunately no resolution but they are getting the same OLE error. --- This message and any included attachments are from Siemens Medical Solutions USA, Inc. and are intended only for the addressee(s). The information contained herein may include trade secrets or privileged or otherwise confidential information. Unauthorized review, forwarding, printing, copying, distributing, or using such information is strictly prohibited and may be unlawful. If you received this message in error, or have reason to believe you are not authorized to receive it, please promptly delete this message and notify the sender by e-mail with a copy to [EMAIL PROTECTED] Thank you --- This message and any included attachments are from Siemens Medical Solutions USA, Inc. and are intended only for the addressee(s). The information contained herein may include trade secrets or privileged or otherwise confidential information. Unauthorized review, forwarding, printing, copying, distributing, or using such information is strictly prohibited and may be unlawful. If you received this message in error, or have reason to believe you are not authorized to receive it, please promptly delete this message and notify the sender by e-mail with a copy to [EMAIL PROTECTED] Thank you ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE(0.1701) error 0x80005000 when adding a computer to AD using Perl
Hmmm.. I think this is a permissions delegation issue.. Is the IIS Server trusted for delegation? This is of course a security risk... But so is opening IE.. :) Steven From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Zeltov Alex Sent: Tuesday, September 20, 2005 1:06 PM To: perl-win32-users@listserv.ActiveState.com Subject: Win32::OLE(0.1701) error 0x80005000 when adding a computer to AD using Perl I am running into a problem, when I execute a simple script to add a computer to an AD when I do it through a cgi script. This is the code that I am running: my $strBase = OU=iLab - iLab Gatekeeper,OU=InfrApps - Infrastructure Managed Apps,OU=Applications,OU=US-DC1,DC=resdm50,DC=ilab,DC=siemensmedasp,DC=co m; my $strComp = alex; # e.g. joe-xp my $strDescr = none; # e.g. Joe's Windows XP workstation use Win32::OLE; $Win32::OLE::Warn = 3; # $ADS_USER_FLAG_ENUM my $ADS_UF_WORKSTATION_TRUST_ACCOUNT = 0x1000; my $objCont = Win32::OLE-GetObject(LDAP:// . $strBase); my $objComp = $objCont-Create(computer, cn= . $strComp); $objComp-Put(sAMAccountName, $strComp . \$); #$objComp-Put(description, $strDesc); $objComp-Put(userAccountControl, $ADS_UF_WORKSTATION_TRUST_ACCOUNT); $objComp-SetInfo; This code works fine when I run it as a stand alone program. When it runs under IIS, as cgi I am running into this error: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: Win32::OLE(0.1701) error 0x80005000 after character 0 in LDAP://OU=US-DC1,DC=resdm50,DC=ilab,DC=siemensmedasp,DC=com at F:\ttx218\dev\joincomputer.pl line 22 eval {...} called at F:\ttx218\dev\joincomputer.pl line 22 I have integrated windows authentication enabled, so the script runs under the same security permissions when i run it as IIS or as stand alone. Has anyone encountered this issue? I have googled this error and found a couple of threads having similar issue http://lists.ee.ethz.ch/realmen/msg00035.html Unfortunately no resolution but they are getting the same OLE error. --- This message and any included attachments are from Siemens Medical Solutions USA, Inc. and are intended only for the addressee(s). The information contained herein may include trade secrets or privileged or otherwise confidential information. Unauthorized review, forwarding, printing, copying, distributing, or using such information is strictly prohibited and may be unlawful. If you received this message in error, or have reason to believe you are not authorized to receive it, please promptly delete this message and notify the sender by e-mail with a copy to [EMAIL PROTECTED] Thank you ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE(0.1701) error 0x80005000 when adding a computer to AD using Perl
The line This code works fine when I run it as a stand alone program leads me to believe it is a permission issue. Integrated Windows Authentication does not work well when your script needs to access a third system (in this case the domain controller). Try switching to basic authentication and see if you have better luck. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Zeltov Alex Sent: Tuesday, September 20, 2005 1:06 PM To: perl-win32-users@listserv.ActiveState.com Subject: Win32::OLE(0.1701) error 0x80005000 when adding a computer to AD using Perl I am running into a problem, when I execute a simple script to add a computer to an AD when I do it through a cgi script. This is the code that I am running: my $strBase = OU=iLab - iLab Gatekeeper,OU=InfrApps - Infrastructure Managed Apps,OU=Applications,OU=US-DC1,DC=resdm50,DC=ilab,DC=siemensmedasp,DC=com; my $strComp = alex; # e.g. joe-xp my $strDescr = none; # e.g. Joe's Windows XP workstation use Win32::OLE; $Win32::OLE::Warn = 3; # $ADS_USER_FLAG_ENUM my $ADS_UF_WORKSTATION_TRUST_ACCOUNT = 0x1000; my $objCont = Win32::OLE-GetObject(LDAP:// . $strBase); my $objComp = $objCont-Create(computer, cn= . $strComp); $objComp-Put(sAMAccountName, $strComp . \$); #$objComp-Put(description, $strDesc); $objComp-Put(userAccountControl, $ADS_UF_WORKSTATION_TRUST_ACCOUNT); $objComp-SetInfo; This code works fine when I run it as a stand alone program. When it runs under IIS, as cgi I am running into this error: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: Win32::OLE(0.1701) error 0x80005000 after character 0 in LDAP://OU=US-DC1,DC=resdm50,DC=ilab,DC=siemensmedasp,DC=com at F:\ttx218\dev\joincomputer.pl line 22 eval {...} called at F:\ttx218\dev\joincomputer.pl line 22 I have integrated windows authentication enabled, so the script runs under the same security permissions when i run it as IIS or as stand alone. Has anyone encountered this issue? I have googled this error and found a couple of threads having similar issue http://lists.ee.ethz.ch/realmen/msg00035.html Unfortunately no resolution but they are getting the same OLE error. --- This message and any included attachments are from Siemens Medical Solutions USA, Inc. and are intended only for the addressee(s). The information contained herein may include trade secrets or privileged or otherwise confidential information. Unauthorized review, forwarding, printing, copying, distributing, or using such information is strictly prohibited and may be unlawful. If you received this message in error, or have reason to believe you are not authorized to receive it, please promptly delete this message and notify the sender by e-mail with a copy to [EMAIL PROTECTED] Thank you ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: win32::ole Event handling - IE(DOM)
iVAN G wrote: As i read here (back from 1999) : http://aspn.activestate.com/ASPN/Mail/Message/perl-win32-users/261942 i dont seem to find this Forward method ? is it here ? Yes, it is there, just not documented, as it is just a hack... Did you actually try (and understand) the code in that message? It did work when I posted it in 1999. I don't know if it needs changes for the latest versions of IE or not. Now what next, I want to recieve all DOM generated events and act on them. The event sink way will not work very well here !! Sorry, I have no time to play with this. Maybe somebody else can help you. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32:OLE Excel
Removing the () seems to work, but only if I am adding one worksheet. I am using a For Loop to add multiple sheets, but all the other sheets are default named Sheet2, Sheet3, etc... So, some more investigation. Thanks, David -Original Message- From: Dave Kazatsky [mailto:[EMAIL PROTECTED] Sent: Thursday, August 04, 2005 1:47 PM To: Hsu, David Cc: Perl-Win32-Users@listserv.ActiveState.com; [EMAIL PROTECTED] Subject: RE: Win32:OLE Excel David, I have a script with almost the exact same code and it works correctly. Try removing the parens from your add statement and see if that makes a difference. Original Code: $Worksheet = $Workbook-Worksheets()-Add(); $Worksheet-{Name} = test $i; Becomes: $Worksheet = $Workbook-Worksheets-Add; $Worksheet-{Name} = test $i; HTH. Dave Kazatsky Senior Middleware Engineer W. (908) 575-6947 C. (973) 865-8106 |-+- | | Hsu, David [EMAIL PROTECTED]| | | Sent by: | | | [EMAIL PROTECTED]| | | veState.com | | | | | | | | | 08/04/2005 01:17 PM | | | | |-+- --- ---| | | | To: Ken Barker [EMAIL PROTECTED], | |Perl-Win32-Users@listserv.ActiveState.com | | cc: | | Subject: RE: Win32:OLE Excel | --- ---| Ken, I am using Win32::OLE. Add_worksheet uses the Spreadsheet:WriteExcel module. Thanks, David -Original Message- From: Ken Barker [mailto:[EMAIL PROTECTED] Sent: Thursday, August 04, 2005 12:07 PM To: Hsu, David; Perl-Win32-Users@listserv.ActiveState.com Subject: RE: Win32:OLE Excel Try $ws1 = $workbook-add_worksheet('worksheetname'); Ken Barker IT Lead Americall Group, Inc 314-213-7927 [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Hsu, David Sent: Thursday, August 04, 2005 10:23 AM To: Perl-Win32-Users@listserv.ActiveState.com Subject: Win32:OLE Excel Hi, Does someone know of another method of naming the Excel sheets? Currently I am using: ... $Worksheet = $Workbook-Worksheets()-Add(); $Worksheet-{Name} = test $i; ... The sheet names are still Sheet1, Sheet2, etc... Thanks, David ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs __ This e-mail has been scanned by MCI Managed Email Content Service, using Skeptic(tm) technology powered by MessageLabs. For more information on MCI's Managed Email Content Service, visit http://www.mci.com. __ ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs The information contained in this message may be CONFIDENTIAL and is for the intended addressee only. Any unauthorized use, dissemination of the information, or copying of this message is prohibited. If you are not the intended addressee, please notify the sender immediately and delete this message. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32:OLE Excel
Dave, I attack this a little differently, I allow the excel to create sheet1 sheet2 and sheet3. which I believe are created by default. First create all the sheets that you need by looping around $Sheet = $Book-Worksheets-Add; $Sheet-{Name} = $NEW_NAME; Then delete all the sheets that start with sheet $SheetTabName = $Book- Worksheets($_)-{Name}; foreach ( 1...$SheetCnt) { $SheetTabName = $Book- Worksheets($_)-{Name}; if ( $SheetTabName =~ /^sheet/i ) { $Book-Worksheets($SheetTabName)-Delete; } } Later, Matt Ross Motorola Configuration Management ePIMS -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hsu, David Sent: Friday, August 05, 2005 7:58 AM To: Dave Kazatsky Cc: Perl-Win32-Users@listserv.ActiveState.com; [EMAIL PROTECTED] Subject: RE: Win32:OLE Excel Removing the () seems to work, but only if I am adding one worksheet. I am using a For Loop to add multiple sheets, but all the other sheets are default named Sheet2, Sheet3, etc... So, some more investigation. Thanks, David -Original Message- From: Dave Kazatsky [mailto:[EMAIL PROTECTED] Sent: Thursday, August 04, 2005 1:47 PM To: Hsu, David Cc: Perl-Win32-Users@listserv.ActiveState.com; [EMAIL PROTECTED] Subject: RE: Win32:OLE Excel David, I have a script with almost the exact same code and it works correctly. Try removing the parens from your add statement and see if that makes a difference. Original Code: $Worksheet = $Workbook-Worksheets()-Add(); $Worksheet-{Name} = test $i; Becomes: $Worksheet = $Workbook-Worksheets-Add; $Worksheet-{Name} = test $i; HTH. Dave Kazatsky Senior Middleware Engineer W. (908) 575-6947 C. (973) 865-8106 |-+- | | Hsu, David [EMAIL PROTECTED]| | | Sent by: | | | [EMAIL PROTECTED]| | | veState.com | | | | | | | | | 08/04/2005 01:17 PM | | | | |-+- --- ---| | | | To: Ken Barker [EMAIL PROTECTED], | |Perl-Win32-Users@listserv.ActiveState.com | | cc: | | Subject: RE: Win32:OLE Excel | --- ---| Ken, I am using Win32::OLE. Add_worksheet uses the Spreadsheet:WriteExcel module. Thanks, David -Original Message- From: Ken Barker [mailto:[EMAIL PROTECTED] Sent: Thursday, August 04, 2005 12:07 PM To: Hsu, David; Perl-Win32-Users@listserv.ActiveState.com Subject: RE: Win32:OLE Excel Try $ws1 = $workbook-add_worksheet('worksheetname'); Ken Barker IT Lead Americall Group, Inc 314-213-7927 [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Hsu, David Sent: Thursday, August 04, 2005 10:23 AM To: Perl-Win32-Users@listserv.ActiveState.com Subject: Win32:OLE Excel Hi, Does someone know of another method of naming the Excel sheets? Currently I am using: ... $Worksheet = $Workbook-Worksheets()-Add(); $Worksheet-{Name} = test $i; ... The sheet names are still Sheet1, Sheet2, etc... Thanks, David ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs __ This e-mail has been scanned by MCI Managed Email Content Service, using Skeptic(tm) technology powered by MessageLabs. For more information on MCI's Managed Email Content Service, visit http://www.mci.com. __ ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs The information contained in this message may be CONFIDENTIAL and is for the intended addressee only. Any unauthorized use, dissemination of the information, or copying of this message is prohibited. If you are not the intended addressee, please notify the sender immediately and delete this message. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman
RE: Win32:OLE Excel
Then delete all the sheets that start with sheet $SheetTabName = $Book- Worksheets($_)-{Name}; foreach ( 1...$SheetCnt) { $SheetTabName = $Book- Worksheets($_)-{Name}; if ( $SheetTabName =~ /^sheet/i ) { $Book-Worksheets($SheetTabName)-Delete; } } Or just $Book-Worksheets(Sheet $_)-Delete for 1..3; -- Mark. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32:OLE Excel
Try $ws1 = $workbook-add_worksheet('worksheetname'); Ken Barker IT Lead Americall Group, Inc 314-213-7927 [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Hsu, David Sent: Thursday, August 04, 2005 10:23 AM To: Perl-Win32-Users@listserv.ActiveState.com Subject: Win32:OLE Excel Hi, Does someone know of another method of naming the Excel sheets? Currently I am using: ... $Worksheet = $Workbook-Worksheets()-Add(); $Worksheet-{Name} = test $i; ... The sheet names are still Sheet1, Sheet2, etc... Thanks, David ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs __ This e-mail has been scanned by MCI Managed Email Content Service, using Skeptic(tm) technology powered by MessageLabs. For more information on MCI's Managed Email Content Service, visit http://www.mci.com. __ ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32:OLE Excel
Hsu, David wrote: Hi, Does someone know of another method of naming the Excel sheets? Currently I am using: ... $Worksheet = $Workbook-Worksheets()-Add(); $Worksheet-{Name} = test $i; ... The sheet names are still Sheet1, Sheet2, etc... my $workbook = $Excel-Workbooks-Add(); my $worksheet = $workbook-Worksheets(1); $worksheet-{Name} = First Sheet; -- ,-/- __ _ _ $Bill LuebkertMailto:[EMAIL PROTECTED] (_/ / )// // DBE CollectiblesMailto:[EMAIL PROTECTED] / ) /-- o // // Castle of Medieval Myth Magic http://www.todbe.com/ -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32:OLE Excel
Ken, I am using Win32::OLE. Add_worksheet uses the Spreadsheet:WriteExcel module. Thanks, David -Original Message- From: Ken Barker [mailto:[EMAIL PROTECTED] Sent: Thursday, August 04, 2005 12:07 PM To: Hsu, David; Perl-Win32-Users@listserv.ActiveState.com Subject: RE: Win32:OLE Excel Try $ws1 = $workbook-add_worksheet('worksheetname'); Ken Barker IT Lead Americall Group, Inc 314-213-7927 [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Hsu, David Sent: Thursday, August 04, 2005 10:23 AM To: Perl-Win32-Users@listserv.ActiveState.com Subject: Win32:OLE Excel Hi, Does someone know of another method of naming the Excel sheets? Currently I am using: ... $Worksheet = $Workbook-Worksheets()-Add(); $Worksheet-{Name} = test $i; ... The sheet names are still Sheet1, Sheet2, etc... Thanks, David ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs __ This e-mail has been scanned by MCI Managed Email Content Service, using Skeptic(tm) technology powered by MessageLabs. For more information on MCI's Managed Email Content Service, visit http://www.mci.com. __ ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32:OLE Excel
David, I have a script with almost the exact same code and it works correctly. Try removing the parens from your add statement and see if that makes a difference. Original Code: $Worksheet = $Workbook-Worksheets()-Add(); $Worksheet-{Name} = test $i; Becomes: $Worksheet = $Workbook-Worksheets-Add; $Worksheet-{Name} = test $i; HTH. Dave Kazatsky Senior Middleware Engineer W. (908) 575-6947 C. (973) 865-8106 Hsu, David [EMAIL PROTECTED] Hsu, David [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 08/04/2005 01:17 PM To: Ken Barker [EMAIL PROTECTED], Perl-Win32-Users@listserv.ActiveState.com cc: Subject: RE: Win32:OLE Excel Ken, I am using Win32::OLE. Add_worksheet uses the Spreadsheet:WriteExcel module. Thanks, David -Original Message- From: Ken Barker [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 04, 2005 12:07 PM To: Hsu, David; Perl-Win32-Users@listserv.ActiveState.com Subject: RE: Win32:OLE Excel Try $ws1 = $workbook-add_worksheet('worksheetname'); Ken Barker IT Lead Americall Group, Inc 314-213-7927 [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Hsu, David Sent: Thursday, August 04, 2005 10:23 AM To: Perl-Win32-Users@listserv.ActiveState.com Subject: Win32:OLE Excel Hi, Does someone know of another method of naming the Excel sheets? Currently I am using: ... $Worksheet = $Workbook-Worksheets()-Add(); $Worksheet-{Name} = test $i; ... The sheet names are still Sheet1, Sheet2, etc... Thanks, David ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs __ This e-mail has been scanned by MCI Managed Email Content Service, using Skeptic(tm) technology powered by MessageLabs. For more information on MCI's Managed Email Content Service, visit http://www.mci.com. __ ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs The information contained in this message may be CONFIDENTIAL and is for the intended addressee only. Any unauthorized use, dissemination of the information, or copying of this message is prohibited. If you are not the intended addressee, please notify the sender immediately and delete this message. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32:OLE - Speech.VoiceText
Jon Bjornstad wrote: This code: use Win32::Ole; my $voice = Win32::Ole-new(Speech.VoiceText); $voice-Register('', 'Perl'); $voice-speak(hello world); STDIN;# wait til it finishes speaking has been used succesfully on Windows98 (with the Microsoft Speech SDK installed) and on Windows 2000 (which has it installed by default, apparently). The same code does not, however, work on Windows XP. What has changed? There IS a text-to-speech service on XP. How do I connect to it? I got it working on XP Pro after switching to Jan's classname : use strict; use warnings; use Win32::OLE; my $voice = Win32::OLE-new('SAPI.SpVoice'); # Speech.VoiceText); # $voice-Register('', 'Perl'); $voice-speak(hello world); STDIN;# wait til it finishes speaking __END__ and the tie example also: use strict; use warnings; use Win32::OLE; tie *SPEECH, 'Speech'; END { untie *SPEECH; } print SPEECH It is now , scalar localtime; exit; package Speech; sub TIEHANDLE { my $voice = Win32::OLE-new('SAPI.SpVoice') or die new SAPI.SPVoice: $! ($^E); # $voice-Register('', 'Perl'); bless \$voice = shift; } sub PRINT { my $voice = shift; my $text = join '', @_; print STDOUT $text, \n; $$voice-Speak($text, 0); } sub DESTROY { my $voice = shift; # sleep (1) while $$voice-IsSpeaking; my $ret = $$voice-WaitUntilDone(1000); # print ret=, $ret ? 'finished' : 'killed', \n; } __END__ -- ,-/- __ _ _ $Bill LuebkertMailto:[EMAIL PROTECTED] (_/ / )// // DBE CollectiblesMailto:[EMAIL PROTECTED] / ) /-- o // // Castle of Medieval Myth Magic http://www.todbe.com/ -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32:OLE - Speech.VoiceText
Oh great! It works this way. Teddy - Original Message - From: Jan Dubois [EMAIL PROTECTED] To: 'Sisyphus' [EMAIL PROTECTED]; perl-win32-users@listserv.ActiveState.com; 'Jon Bjornstad' [EMAIL PROTECTED] Sent: Tuesday, June 14, 2005 5:19 AM Subject: RE: Win32:OLE - Speech.VoiceText On Mon, 13 Jun 2005, Sisyphus wrote: - Original Message - On Tue, 14 Jun 2005, Jon Bjornstad [EMAIL PROTECTED] wrote: This code: use Win32::Ole; my $voice = Win32::Ole-new(Speech.VoiceText); $voice-Register('', 'Perl'); $voice-speak(hello world); STDIN;# wait til it finishes speaking has been used succesfully on Windows98 (with the Microsoft Speech SDK installed) and on Windows 2000 (which has it installed by default, apparently). Doesn't work for me on Windows 2000. Even after I correct the typos (both instances of Ole need to be replaced with OLE) and 'use warnings;' all I get is: Win32::OLE(0.1502) error 0x8002000e: Invalid number of parameters in METHOD/PROPERTYGET speak at speak.pl line 5 Does 'use warnings;' result in the same warning on XP ? I think Speak() takes 2 arguments. At least it did when I played with it for my OSCON talk in 1999: http://opensource.activestate.com/authors/jandubois/Perl/TPC3/fun.html#Can_I_access_COM_OLE_objects_f So try something like $voice-speak(hello world, 0); in the script above. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32:OLE - Speech.VoiceText
I have also tried the following script under Windows 2000 but it doesn't work and it doesn't give any error. The SAPI 4 is installed by default in Windows 2000 and it works fine with Narrator and with my screen reader so this is not a problem. Under Windows XP SAPI 5 is installed by default, and it might have a little different syntax... But I am wondering why this script doesn't work... use strict; use warnings; use Win32::OLE; my $voice = Win32::OLE-new(Speech.VoiceText); $voice-Register('', 'Perl'); $voice-speak(hello world); STDIN;# wait til it finishes speaking - Original Message - From: Sisyphus [EMAIL PROTECTED] To: perl-win32-users@listserv.ActiveState.com; Jon Bjornstad [EMAIL PROTECTED] Sent: Tuesday, June 14, 2005 4:30 AM Subject: Re: Win32:OLE - Speech.VoiceText - Original Message - From: Jon Bjornstad [EMAIL PROTECTED] To: perl-win32-users@listserv.ActiveState.com Sent: Tuesday, June 14, 2005 9:26 AM Subject: Win32:OLE - Speech.VoiceText This code: use Win32::Ole; my $voice = Win32::Ole-new(Speech.VoiceText); $voice-Register('', 'Perl'); $voice-speak(hello world); STDIN;# wait til it finishes speaking has been used succesfully on Windows98 (with the Microsoft Speech SDK installed) and on Windows 2000 (which has it installed by default, apparently). Doesn't work for me on Windows 2000. Even after I correct the typos (both instances of Ole need to be replaced with OLE) and 'use warnings;' all I get is: Win32::OLE(0.1502) error 0x8002000e: Invalid number of parameters in METHOD/PROPERTYGET speak at speak.pl line 5 Does 'use warnings;' result in the same warning on XP ? Cheers, Rob ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32:OLE - Speech.VoiceText
Octavian - The script below still has the error that I originally introduced. It should be $voice-Speak(hello world, 0); Thanks to Jan for the research! So now I can code like this: use Win32; my $speech_object = (Win32::GetOSName() =~ /XP/)? SAPI.SpVoice: Speech.VoiceText; use Win32::OLE; my $voice = Win32::OLE-new($speech_object); and all will be well. Thanks a Million! Jon On Jun 13, 2005, at 11:27 PM, Octavian Rasnita wrote: I have also tried the following script under Windows 2000 but it doesn't work and it doesn't give any error. The SAPI 4 is installed by default in Windows 2000 and it works fine with Narrator and with my screen reader so this is not a problem. Under Windows XP SAPI 5 is installed by default, and it might have a little different syntax... But I am wondering why this script doesn't work... use strict; use warnings; use Win32::OLE; my $voice = Win32::OLE-new(Speech.VoiceText); $voice-Register('', 'Perl'); $voice-speak(hello world); STDIN;# wait til it finishes speaking - Original Message - From: Sisyphus [EMAIL PROTECTED] To: perl-win32-users@listserv.ActiveState.com; Jon Bjornstad [EMAIL PROTECTED] Sent: Tuesday, June 14, 2005 4:30 AM Subject: Re: Win32:OLE - Speech.VoiceText - Original Message - From: Jon Bjornstad [EMAIL PROTECTED] To: perl-win32-users@listserv.ActiveState.com Sent: Tuesday, June 14, 2005 9:26 AM Subject: Win32:OLE - Speech.VoiceText This code: use Win32::Ole; my $voice = Win32::Ole-new(Speech.VoiceText); $voice-Register('', 'Perl'); $voice-speak(hello world); STDIN;# wait til it finishes speaking has been used succesfully on Windows98 (with the Microsoft Speech SDK installed) and on Windows 2000 (which has it installed by default, apparently). Doesn't work for me on Windows 2000. Even after I correct the typos (both instances of Ole need to be replaced with OLE) and 'use warnings;' all I get is: Win32::OLE(0.1502) error 0x8002000e: Invalid number of parameters in METHOD/PROPERTYGET speak at speak.pl line 5 Does 'use warnings;' result in the same warning on XP ? Cheers, Rob ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32:OLE - Speech.VoiceText
--8--- has been used succesfully on Windows98 (with the Microsoft Speech SDK installed) and on Windows 2000 (which has it installed by default, apparently). The same code does not, however, work on Windows XP. What has changed? There IS a text-to-speech service on XP. How do I connect to it? --8--- Check this out http://www.microsoft.com/products/msagent/support/user/tts.asp and make sure you can hear an agent after you have setup accordingly. Seems that Windblows changes direction as wantonly as the wind does. Just in Due to the reference to certain OS' in this e-mail I need to state that all opinions and inferences herein are mine, and do not reflect my company's in any shape or form. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32:OLE - Speech.VoiceText
- Original Message - From: Jon Bjornstad [EMAIL PROTECTED] To: perl-win32-users@listserv.ActiveState.com Sent: Tuesday, June 14, 2005 9:26 AM Subject: Win32:OLE - Speech.VoiceText This code: use Win32::Ole; my $voice = Win32::Ole-new(Speech.VoiceText); $voice-Register('', 'Perl'); $voice-speak(hello world); STDIN;# wait til it finishes speaking has been used succesfully on Windows98 (with the Microsoft Speech SDK installed) and on Windows 2000 (which has it installed by default, apparently). Doesn't work for me on Windows 2000. Even after I correct the typos (both instances of Ole need to be replaced with OLE) and 'use warnings;' all I get is: Win32::OLE(0.1502) error 0x8002000e: Invalid number of parameters in METHOD/PROPERTYGET speak at speak.pl line 5 Does 'use warnings;' result in the same warning on XP ? Cheers, Rob ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32:OLE - Speech.VoiceText
On Mon, 13 Jun 2005, Sisyphus wrote: - Original Message - On Tue, 14 Jun 2005, Jon Bjornstad [EMAIL PROTECTED] wrote: This code: use Win32::Ole; my $voice = Win32::Ole-new(Speech.VoiceText); $voice-Register('', 'Perl'); $voice-speak(hello world); STDIN;# wait til it finishes speaking has been used succesfully on Windows98 (with the Microsoft Speech SDK installed) and on Windows 2000 (which has it installed by default, apparently). Doesn't work for me on Windows 2000. Even after I correct the typos (both instances of Ole need to be replaced with OLE) and 'use warnings;' all I get is: Win32::OLE(0.1502) error 0x8002000e: Invalid number of parameters in METHOD/PROPERTYGET speak at speak.pl line 5 Does 'use warnings;' result in the same warning on XP ? I think Speak() takes 2 arguments. At least it did when I played with it for my OSCON talk in 1999: http://opensource.activestate.com/authors/jandubois/Perl/TPC3/fun.html#Can_I_access_COM_OLE_objects_f So try something like $voice-speak(hello world, 0); in the script above. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32:OLE - Speech.VoiceText
Sisyphus, Jan, all, Right. I'm sitting here copying code between an un-networked Win98 laptop, an XP machine and my Apple iBook and apologize for the sloppy copying. This code does work on Win98 (with the Speech SDK installed) and Win2000 (stock) but not on XP: use Win::OLE; my $voice = Win32::OLE-new('Speech.VoiceText'); die no voice: $!\n unless $voice; $voice-Register('', 'Perl'); while (STDIN) { $voice-Speak($_, 0); } On XP it dies with no voice: and nothing in $!. On XP I can go into the Control Panel and choose Speech and in the Text to Speech tab I can set the voice and preview it successfully. But apparently there is no Speech.VoiceText object created for Win32::OLE to connect to. XP Help says something about installing 3rd party Text-to-Speech products. Do I need to install the MS Speech SDK on XP? It is downloadable at: http://www.microsoft.com/speech/download/sdk51/ (this is a large download -68 megs- including speech recognition which i do not need). Was it on Win2000 automatically? What kind of text-to-speech engine is by default present on XP? Jan - the article you wrote in 1999 was instrumental in my getting the code to work on Win98. It was for a Perl/Tk program to help a handicapped friend of mine communicate. Here's an article written about it: http://www.perl.com/pub/a/2001/08/27/bjornstad.html Now I have found another person to use this software and they are running XP... Thanks so much for any clues! Jon On Jun 13, 2005, at 7:19 PM, Jan Dubois wrote: On Mon, 13 Jun 2005, Sisyphus wrote: - Original Message - On Tue, 14 Jun 2005, Jon Bjornstad [EMAIL PROTECTED] wrote: This code: use Win32::Ole; my $voice = Win32::Ole-new(Speech.VoiceText); $voice-Register('', 'Perl'); $voice-speak(hello world); STDIN;# wait til it finishes speaking has been used succesfully on Windows98 (with the Microsoft Speech SDK installed) and on Windows 2000 (which has it installed by default, apparently). Doesn't work for me on Windows 2000. Even after I correct the typos (both instances of Ole need to be replaced with OLE) and 'use warnings;' all I get is: Win32::OLE(0.1502) error 0x8002000e: Invalid number of parameters in METHOD/PROPERTYGET speak at speak.pl line 5 Does 'use warnings;' result in the same warning on XP ? I think Speak() takes 2 arguments. At least it did when I played with it for my OSCON talk in 1999: http://opensource.activestate.com/authors/jandubois/Perl/TPC3/ fun.html#Can_I_access_COM_OLE_objects_f So try something like $voice-speak(hello world, 0); in the script above. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32:OLE - Speech.VoiceText
On Mon, 13 Jun 2005, Jon Bjornstad wrote: This code does work on Win98 (with the Speech SDK installed) and Win2000 (stock) but not on XP: use Win::OLE; my $voice = Win32::OLE-new('Speech.VoiceText'); die no voice: $!\n unless $voice; $voice-Register('', 'Perl'); while (STDIN) { $voice-Speak($_, 0); } On XP it dies with no voice: and nothing in $!. It looks like Speech.VoiceText is a SAPI 4.0 only object and not installed on Windows XP. You can download and install it, but it may be easier to use the SAPI 5.1 engine already built into XP. Here is a trivial sample that works on my Tablet PC: use strict; use Win32::OLE; my $voice = Win32::OLE-new('SAPI.SpVoice'); $voice-Speak(Hi there); I just did a little bit of registry spelunking and browsing of the documentation at: http://www.microsoft.com/speech/download/sdk51/ The documentation doesn't really cove later binding at all, and the number of objects and methods seems overly complex, but this _could_ be a fun project to make it do something more complex. Please send me some sample code if you do work with things like events etc. :) Cheers, -Jan PS: The Table PC edition of XP is slightly different than plain XP, so it is possible that SAPI 5.1 isn't preinstalled, but I don't have another system right now to test. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32:OLE - Speech.VoiceText
- Original Message - From: Jon Bjornstad [EMAIL PROTECTED] To: Jan Dubois [EMAIL PROTECTED] Cc: 'Sisyphus' [EMAIL PROTECTED]; perl-win32-users@listserv.ActiveState.com Sent: Tuesday, June 14, 2005 1:13 PM Subject: Re: Win32:OLE - Speech.VoiceText Sisyphus, Jan, all, Right. I'm sitting here copying code between an un-networked Win98 laptop, an XP machine and my Apple iBook and apologize for the sloppy copying. This code does work on Win98 (with the Speech SDK installed) and Win2000 (stock) but not on XP: use Win::OLE; my $voice = Win32::OLE-new('Speech.VoiceText'); die no voice: $!\n unless $voice; $voice-Register('', 'Perl'); while (STDIN) { $voice-Speak($_, 0); } On XP it dies with no voice: and nothing in $!. It's working for me now on Windows 2000. I don't think I can help with the XP issue so I'll leave that to the experts, but you really should 'use warnings;' - especially if a script is not running as you would like. That will often give you a clue to the source of the problem (though I don't think it will help in this particular instance). As well as looking at $!, you might also try looking at Win32::FormatMessage(Win32::GetLastError()), as that often gives much a better indication of the problem where windows processes are involved. (You have to 'use Win32;' to do that.) One other thing I noticed is that if vcmd.exe is already running, you don't have to 'STDIN'. The script can exit immediately and the speech will continue. But if the script is going to start up vcmd.exe (and kill it on exit) then obviously the script cannot exit until the speech has finished. I used sleep(2) instead of 'STDIN'. Using 'STDIN' I had to exit with Ctrl-C, and then vcmd.exe is not closed (you can still see it as a running process in Task Manager). Cheers, Rob ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE Can you call ShowOpen Method
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: May 23, 2005 7:01 PM To: perl-win32-users@listserv.ActiveState.com Subject: Win32::OLE Can you call ShowOpen Method Hello All, I would like to use OLE to access the common dialog control. I can get access to a number of methods however the ShowOpen does not work. Is it possible to use show open to get a File Open Dialog. I can do this using Win32::GUI and TK, however it would be neat to do it here. Any help would be great. Mark Olegui.pl -w; use strict; use Win32::OLE; my $CommDlg = Win32::OLE-new(MSComDlg.CommonDialog)|| die Could not start Common Dialog\n; $CommDlg-ShowPrinter; $CommDlg-AboutBox; It looks like OLE wants a few properties to be defined first. Defining only MaxFileSize did it for me - but I would also add the filters you want too. $CommDlg-{MaxFileSize} = 400; $CommDlg-{Filter} = All(*.*)|\*.\*; $CommDlg-ShowOpen; Another option is Win32::FileOp::OpenDialog Jack ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE question
Have you tried searching the hard drive for another version of that dll? Dll's located in a local / same folder as the application normally do not need to be registered I believe. They also get invoked before dlls in system32 or other folder. Mike At 05:29 PM 5/9/2005, Chris Cappelletti wrote: I have a line of code that gives an error. This line of code: my $dll = new Win32::OLE(Artwork.db.api); Gives this error: Win32::OLE(0.1403) error 0x800401f3: Invalid class string at (eval 34) line 1 To me this indicates that the dll is not registered correctly with windows. That is not however the case. I can use the dll from the language it was written in as well as a different language that supports OLE and also using SQL servers' sp_OACreate. I can also see everything fine using Jan's OLE-Browser. Not sure what else could cause this...I have tried re-registering the dll many times. I have manually cleaned every reference to it out of the registry and re registered it. To no avail, ideas? ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32 OLE issue, maybe
-How much did you copy and how did you go about it? It sounds like you partially overwrote the -second computer's copy of Win32::OLE with a different version. Try using PPM to reinstall -Win32::OLE. I didn't copy any of the perl stuff. I installed a fresh copy of perl and then used PPM to install all of the modules that I needed. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32 OLE issue, maybe
How much did you copy and how did you go about it? It sounds like you partially overwrote the second computer's copy of Win32::OLE with a different version. Try using PPM to reinstall Win32::OLE. Make sure you are only copying the modules you need. Overwriting important modules such as Win32::OLE can cause headaches down the road. In the future, if you have a choice install modules cleanly with PPM or by downloading from CPAN. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Chris Cappelletti Sent: Wednesday, May 04, 2005 11:38 AM To: perl-win32-users@listserv.ActiveState.com Subject: Win32 OLE issue, maybe Here's the situation. I have some perl code running fine on one windows box. I moved it to another box and installed all the appropriate modules. I am now getting the following message in my error log: Win32::OLE object version 0.1702 does not match $Win32::OLE::VERSION 0.1403 at C:/Perl/lib/DynaLoader.pm line 253 Anyone have any idea where I should look? ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE behavior on IMessageFilter::HandleIncomingMessageSERVERCALL_RETRYLATER
On Wed, 13 Apr 2005, Jeff Schultz wrote: The other side of this is that calling my COM server which implements IMessageFilter from an (ATL) COM client seems to work ok. So I am guessing that perhaps ATL provides a default client implementation of IMessageFilter::RetryRejectedCall which actually retries the call while Perl Win32::OLE does not provide this implementation. I did a quick grep of the Win32::OLE source and found no references to IMessageFilter, RetryRejected, or anything like that but I could have missed something. All I want is for my COM call to be retried until the server ultimately determines it is ok to process and returns SERVERCALL_ISHANDLED. Win32::OLE only implements OLE Automation (access to IDispatch interfaces). If you want transparent retries from scripting languages then you need to implement this in your IDispatch interface implementation yourself. Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE behavior on IMessageFilter::HandleIncomingMessageSERVERCALL_RETRYLATER
On 4/13/05, Jan Dubois [EMAIL PROTECTED] wrote: Win32::OLE only implements OLE Automation (access to IDispatch interfaces). If you want transparent retries from scripting languages then you need to implement this in your IDispatch interface implementation yourself. Thanks for the response. That was kind of what I was guessing. I will probably go with a more brute force approach and handle the retries myself in Perl, or marshal my calls through another COM server (which I already have laying around anyway for this app) which will handle the retries transparently. Once again, thanks for your help. Jeff ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE - Setting VBA property
On Tue, 08 Mar 2005, Suresh Govindachar wrote: Hello, If myDestination is a folder in Microsoft Outlook VBA code, it is possible to execute a VBA line such as the following: myDestination.Items(1).UnRead = 1 This will mark the first mail inside the folder myDestination as unread (setting the mail item's UnRead property to true). I tried doing the same thing in perl with lines such as: $my_destination-Items(1)-UnRead = 1; and $my_destination-Items(1)-UnRead(1); $my_destination-Items(1)-{UnRead} = 1; Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32:OLE - Threadsafe?
On Mon, 28 Feb 2005 13:12:40 +0100, Neil Burnett [EMAIL PROTECTED] wrote: Has anything happened to solve this clean up issue with Win::OLE and threads? Free to wrong pool ... during global destruction I am avoiding the error at the moment by taking jan and paul's advice (thanks) collectively: - require not use Win32::OLE and do it inside the thread sub I have also had to comment out using Win32:OLE:Constants and revert to the actual numbers I need (E.g 65001 instead of Win32::OLE::CP_UTF8() ). I couldn't get them to work with use or require either inside or outside the thread sub. Hello Neil, I have been burned by this problem before. It's not really a solution, but what I did to work around the issue is to use semaphores. Example; use DBI; use Win32::OLE; use Win32::OLE::Variant; use Win32::Semaphore; use Win32; [---] $strInsSQL = INSERT INTO tbl (OfficeStreet1) ; $strInsSQL .= VALUES ('.$INFO{'newost1'}.' ; my($Sem); Win32::Semaphore::Create($Sem,1,1,SemBranch)||die Error; if($Sem) { $Sem-wait(); $sth = $dbh-prepare($strInsSQL); $sth-execute || Write_HTML_ERROR_sem(bERROR Writing tblBranches Recordb, $Sem, $lastBranch); $Sem-Release(1,$lastBranch); } ...something not shown is Write_HTML_ERROR_sem() you shouldn't just die if you get an error, because you should at least try to release your named semaphore... otherwise it will jam up everyone else who uses the semaphore. Google about semaphores if you need to get a background. KC ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32:OLE - Threadsafe?
-Original Message- From: Kevin Carothers [mailto:[EMAIL PROTECTED] Sent: Monday, February 28, 2005 6:59 PM To: Neil Burnett Cc: [EMAIL PROTECTED] Subject: Re: Win32:OLE - Threadsafe? On Mon, 28 Feb 2005 13:12:40 +0100, Neil Burnett [EMAIL PROTECTED] wrote: Has anything happened to solve this clean up issue with Win::OLE and threads? Free to wrong pool ... during global destruction I am avoiding the error at the moment by taking jan and paul's advice (thanks) collectively: - require not use Win32::OLE and do it inside the thread sub I have also had to comment out using Win32:OLE:Constants and revert to the actual numbers I need (E.g 65001 instead of Win32::OLE::CP_UTF8() ). I couldn't get them to work with use or require either inside or outside the thread sub. Hello Neil, I have been burned by this problem before. It's not really a solution, but what I did to work around the issue is to use semaphores. Example; use DBI; use Win32::OLE; use Win32::OLE::Variant; use Win32::Semaphore; use Win32; [---] $strInsSQL = INSERT INTO tbl (OfficeStreet1) ; $strInsSQL .= VALUES ('.$INFO{'newost1'}.' ; my($Sem); Win32::Semaphore::Create($Sem,1,1,SemBranch)||die Error; if($Sem) { $Sem-wait(); $sth = $dbh-prepare($strInsSQL); $sth-execute || Write_HTML_ERROR_sem(bERROR Writing tblBranches Recordb, $Sem, $lastBranch); $Sem-Release(1,$lastBranch); } ...something not shown is Write_HTML_ERROR_sem() you shouldn't just die if you get an error, because you should at least try to release your named semaphore... otherwise it will jam up everyone else who uses the semaphore. Google about semaphores if you need to get a background. KC Thanks for the advice. At the moment, my single multi-threaded script is working fine with the arrangement I mentioned above, so I won't venture into semaphore territory unless I need it on the next script. Mind you, reducing my url validation code (it updates a database with the current responses) from 10 hours elapsed execution time to the same number of minutes using threads is very encouraging. I may use threads again much sooner than I thought! Regards - Neil ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE : Bizarre Push while Examining IE Events
I use events with IE automation. use Win32::OLE qw(EVENTS) Then check the Win32::OLE docs or the archive lists to see how to use them. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kevin Carothers Sent: Tuesday, February 22, 2005 4:21 PM To: Andrew McFarlane Cc: perl-win32-users@listserv.ActiveState.com Subject: Re: Win32::OLE : Bizarre Push while Examining IE Events Hi Andrew, I really don't know what's going on, but I have tried running MSAccess as an OLE automation server; you too are obviously running IE as an OLE automation server. I hate it when people tell me something can't be done, but I really doubt that you can call events from a COM object via a perl script... It MAY be possible from a VB program, because (I believe this is how it works) both are bound at runtime via the VB6RT.DLL... but I may be wrong... if you findan answer to this, PLEASE POST I worked on a similar project a few weeks ago- I had to implement a report server in Perl to run MS Access reports and deliver the snapshot (*.snp) to the browser- I discovered that I could not run an OLE method - $access-DoCmd-RunReport() got an error; You cannot run this method at this time this time was a code-phrase for you cannot run this method at ANY time [:-)] I was able to solve my problem by writing a VB program that bridged my OLE automation request from the Perl script, and notified the script via some pretty clunky means that I'm too embarassed to get into here. HTH KC On Sun, 20 Feb 2005 10:09:13 -0700, Andrew McFarlane [EMAIL PROTECTED] wrote: I need help in figuring out how to prevent an exception from occurring when I try to examine Internet Explorer browser events using Win32::OLE. Thanks in advance for your help. I have a library that allows one to drive Internet Explorer. My code runs well until I try to examine the window events by using the Win32::OLE WithEvents method. When I uncomment the line of code that sets the event handler, I get the error message: Bizarre copy of HASH in push at C:/Perl/site/lib/Win32/OLE/Lite.pm line 168 (#2) (P) Perl detected an attempt to copy an internal value that is not copyable. Uncaught exception from user code: Bizarre copy of HASH in push at C:/Perl/site/lib/Win32/OLE/Lite.pm line 168. Line 168 of OLE::Lite is inside of the in method definition--I call that method when I'm iterating through a collection of Win32::OLE IE objects. Here's a snippet of code: I initialize a browser and set the browser event handler: # Launch Internet Explorer. $oleBrowserRef = Win32::OLE-new(InternetExplorer.Application) or croak ${CLASS}::new Could not open an Internet Explorer browser: ,Win32::OLE-LastError(),\n; # Register window events. Win32::OLE-WithEvents($oleBrowserRef, \browserEventHandler, DWebBrowserEvents2); Here is the browser event handler: sub browserEventHandler { my ($browser,$event,@args) = @_; my $URL = $browser-{URL}; if( $DEBUG ) { print DEBUG: ${CLASS}::browserEventHandler: Event: $event ; foreach my $arg (@args) { my $value = $arg; $value = sprintf [%s %s], Win32::OLE-QueryObjectType($value) if UNIVERSAL::isa($value, 'Win32::OLE'); print \targ: $value\n; } print \n; } 1; } Thanks for your help. Andrew McFarlane ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE : Bizarre Push while Examining IE Events
I think that I'm seeing a but in the Win32::OLE::Lite::in method. When I turn on event handling and then iterate through a collection of IE browser objects: my $objectCollection = $document-All(); foreach my $object( in $objectCollection ) { # Blah, blah } I get the Bizarre copy of HASH in push exception. However, if I iterate differently, my $objectCollection = $document-All(); my $numberOfObjects = $objectCollection-{length}; foreach my $i( 0 .. ($numberOfObjects-1) ) { # Blah, blah } I do not get an exception. How do I alert the powers that be about this potential defect? Andrew McFarlane From: Steven Manross [EMAIL PROTECTED] To: Kevin Carothers [EMAIL PROTECTED],Andrew McFarlane [EMAIL PROTECTED] CC: perl-win32-users@listserv.ActiveState.com Subject: RE: Win32::OLE : Bizarre Push while Examining IE Events Date: Wed, 23 Feb 2005 07:08:52 -0700 I use events with IE automation. use Win32::OLE qw(EVENTS) Then check the Win32::OLE docs or the archive lists to see how to use them. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kevin Carothers Sent: Tuesday, February 22, 2005 4:21 PM To: Andrew McFarlane Cc: perl-win32-users@listserv.ActiveState.com Subject: Re: Win32::OLE : Bizarre Push while Examining IE Events Hi Andrew, I really don't know what's going on, but I have tried running MSAccess as an OLE automation server; you too are obviously running IE as an OLE automation server. I hate it when people tell me something can't be done, but I really doubt that you can call events from a COM object via a perl script... It MAY be possible from a VB program, because (I believe this is how it works) both are bound at runtime via the VB6RT.DLL... but I may be wrong... if you findan answer to this, PLEASE POST I worked on a similar project a few weeks ago- I had to implement a report server in Perl to run MS Access reports and deliver the snapshot (*.snp) to the browser- I discovered that I could not run an OLE method - $access-DoCmd-RunReport() got an error; You cannot run this method at this time this time was a code-phrase for you cannot run this method at ANY time [:-)] I was able to solve my problem by writing a VB program that bridged my OLE automation request from the Perl script, and notified the script via some pretty clunky means that I'm too embarassed to get into here. HTH KC On Sun, 20 Feb 2005 10:09:13 -0700, Andrew McFarlane [EMAIL PROTECTED] wrote: I need help in figuring out how to prevent an exception from occurring when I try to examine Internet Explorer browser events using Win32::OLE. Thanks in advance for your help. I have a library that allows one to drive Internet Explorer. My code runs well until I try to examine the window events by using the Win32::OLE WithEvents method. When I uncomment the line of code that sets the event handler, I get the error message: Bizarre copy of HASH in push at C:/Perl/site/lib/Win32/OLE/Lite.pm line 168 (#2) (P) Perl detected an attempt to copy an internal value that is not copyable. Uncaught exception from user code: Bizarre copy of HASH in push at C:/Perl/site/lib/Win32/OLE/Lite.pm line 168. Line 168 of OLE::Lite is inside of the in method definition--I call that method when I'm iterating through a collection of Win32::OLE IE objects. Here's a snippet of code: I initialize a browser and set the browser event handler: # Launch Internet Explorer. $oleBrowserRef = Win32::OLE-new(InternetExplorer.Application) or croak ${CLASS}::new Could not open an Internet Explorer browser: ,Win32::OLE-LastError(),\n; # Register window events. Win32::OLE-WithEvents($oleBrowserRef, \browserEventHandler, DWebBrowserEvents2); Here is the browser event handler: sub browserEventHandler { my ($browser,$event,@args) = @_; my $URL = $browser-{URL}; if( $DEBUG ) { print DEBUG: ${CLASS}::browserEventHandler: Event: $event ; foreach my $arg (@args) { my $value = $arg; $value = sprintf [%s %s], Win32::OLE-QueryObjectType($value) if UNIVERSAL::isa($value, 'Win32::OLE'); print \targ: $value\n; } print \n; } 1; } Thanks for your help. Andrew McFarlane ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32
RE: Win32::OLE : Bizarre Push while Examining IE Events
On Wed, 23 Feb 2005, Andrew McFarlane wrote: I think that I'm seeing a but in the Win32::OLE::Lite::in method. [...] How do I alert the powers that be about this potential defect? Can you send me a complete program that I can use to reproduce the problem? Cheers, -Jan ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE : Bizarre Push while Examining IE Events
Hi Andrew, I really don't know what's going on, but I have tried running MSAccess as an OLE automation server; you too are obviously running IE as an OLE automation server. I hate it when people tell me something can't be done, but I really doubt that you can call events from a COM object via a perl script... It MAY be possible from a VB program, because (I believe this is how it works) both are bound at runtime via the VB6RT.DLL... but I may be wrong... if you findan answer to this, PLEASE POST I worked on a similar project a few weeks ago- I had to implement a report server in Perl to run MS Access reports and deliver the snapshot (*.snp) to the browser- I discovered that I could not run an OLE method - $access-DoCmd-RunReport() got an error; You cannot run this method at this time this time was a code-phrase for you cannot run this method at ANY time [:-)] I was able to solve my problem by writing a VB program that bridged my OLE automation request from the Perl script, and notified the script via some pretty clunky means that I'm too embarassed to get into here. HTH KC On Sun, 20 Feb 2005 10:09:13 -0700, Andrew McFarlane [EMAIL PROTECTED] wrote: I need help in figuring out how to prevent an exception from occurring when I try to examine Internet Explorer browser events using Win32::OLE. Thanks in advance for your help. I have a library that allows one to drive Internet Explorer. My code runs well until I try to examine the window events by using the Win32::OLE WithEvents method. When I uncomment the line of code that sets the event handler, I get the error message: Bizarre copy of HASH in push at C:/Perl/site/lib/Win32/OLE/Lite.pm line 168 (#2) (P) Perl detected an attempt to copy an internal value that is not copyable. Uncaught exception from user code: Bizarre copy of HASH in push at C:/Perl/site/lib/Win32/OLE/Lite.pm line 168. Line 168 of OLE::Lite is inside of the in method definition--I call that method when I'm iterating through a collection of Win32::OLE IE objects. Here's a snippet of code: I initialize a browser and set the browser event handler: # Launch Internet Explorer. $oleBrowserRef = Win32::OLE-new(InternetExplorer.Application) or croak ${CLASS}::new Could not open an Internet Explorer browser: ,Win32::OLE-LastError(),\n; # Register window events. Win32::OLE-WithEvents($oleBrowserRef, \browserEventHandler, DWebBrowserEvents2); Here is the browser event handler: sub browserEventHandler { my ($browser,$event,@args) = @_; my $URL = $browser-{URL}; if( $DEBUG ) { print DEBUG: ${CLASS}::browserEventHandler: Event: $event ; foreach my $arg (@args) { my $value = $arg; $value = sprintf [%s %s], Win32::OLE-QueryObjectType($value) if UNIVERSAL::isa($value, 'Win32::OLE'); print \targ: $value\n; } print \n; } 1; } Thanks for your help. Andrew McFarlane ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE-GetActiveObject not working!
Are you running XP SP2 or recently upgraded? Yes to SP2, but not recent. Recent hot fixes.. auto applied by windows update. Recently trying to use Win32::OLE though, so no help in finding out if this is something new.. but others seem to have similar problems. This returns the value zero: use strict; use Win32::OLE; my $Count = Win32::OLE-EnumAllObjects; You may need to setup your DCOM permissions. Checked that first, but what DCOM permissions, and how do I setup these permissions so that perl.exe has sufficient rights when being run as me? The default permissions are in place, and seem fairly permissive as reported in dcomcnfg. In any case, I believe that the Computer defaults specify that launch permission and activate permission go hand in hand.. no? Since I can launch the application, why wouldn't I be able to activate the application? And.. I am member of Administrator group. Your ID may not have rights to access the COM objects on your local PC. I can use Internet Explorer and the Win32::OLE - Type Library Browser to enumerate objects in Internet Explorer. I can use the Microsoft OLEView application to enumerate and view objects. I can use mmc viewer to adjust security settings of My Computer and individual DCOM items at an administrative level. Under the Component Services mmc you can manage the permissions for your PC My computer, or you can manage individual objects. Yup. Just in case, I added my specific username to the default permissions at the Computer level with access to both local and remote rights in all contexts. What is very odd is that Win32::OLE is unable to enumerate objects, but it *is* allowed to launch them using the same interface. Start-run-dcomcnfg (This will get you into the MMC.) uh huh.. I'm still not certain that this behavior isn't just restricted to my machine and a few other users. Is there a maintainer of the Win32::OLE core who can set the record straight here? Richard - Aaron Tesch -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, January 20, 2005 4:06 PM To: [EMAIL PROTECTED]; perl-win32-users@listserv.ActiveState.com Subject: RE: Win32::OLE-GetActiveObject not working! Richard, I've been having similar difficulty using Win32::OLE with Internet Explorer recently. I wrote code that worked a month ago that doesn't work today. Perl simply can't get an OLE connection to Internet Explorer anymore, even though I can still connect to Excel, etc. Something must have changed in Windows, but I haven't been able to find any related information on the net. Mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Richard Grant Sent: Thursday, January 20, 2005 3:54 PM To: perl-win32-users@listserv.ActiveState.com Subject: RE: Win32::OLE-GetActiveObject not working! I could be wrong, but I don't think iTunes is an OLE Object which could be causing your troubles. Isn't OLE Automation just a layer on COM targeted toward scripting and VB in particular? It's a shame that it doesn't have a direct Perl API. Dunno, but I can do virtually everything with it using Win32::OLE, just this function seems to be acting odd. And it seems to be something that is part of a recent pattern that has root in the RPC layer. Richard ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ** The information contained in this message, including attachments, may contain privileged or confidential information that is intended to be delivered only to the person identified above. If you are not the intended recipient, or the person responsible for delivering this message to the intended recipient, ALLTEL requests that you immediately notify the sender and asks that you do not read the message or its attachments, and that you delete them without copying or sending them to anyone else. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE-GetActiveObject not working!
I have the same problem with new MSN Messenger El Jueves 20 Enero 2005 23:05, [EMAIL PROTECTED] escribió: Richard, I've been having similar difficulty using Win32::OLE with Internet Explorer recently. I wrote code that worked a month ago that doesn't work today. Perl simply can't get an OLE connection to Internet Explorer anymore, even though I can still connect to Excel, etc. Something must have changed in Windows, but I haven't been able to find any related information on the net. Mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Richard Grant Sent: Thursday, January 20, 2005 3:54 PM To: perl-win32-users@listserv.ActiveState.com Subject: RE: Win32::OLE-GetActiveObject not working! I could be wrong, but I don't think iTunes is an OLE Object which could be causing your troubles. Isn't OLE Automation just a layer on COM targeted toward scripting and VB in particular? It's a shame that it doesn't have a direct Perl API. Dunno, but I can do virtually everything with it using Win32::OLE, just this function seems to be acting odd. And it seems to be something that is part of a recent pattern that has root in the RPC layer. Richard ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs *** *** The information contained in this message, including attachments, may contain privileged or confidential information that is intended to be delivered only to the person identified above. If you are not the intended recipient, or the person responsible for delivering this message to the intended recipient, ALLTEL requests that you immediately notify the sender and asks that you do not read the message or its attachments, and that you delete them without copying or sending them to anyone else. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE-GetActiveObject not working!
Are you running XP SP2 or recently upgraded? You may need to setup your DCOM permissions. Your ID may not have rights to access the COM objects on your local PC. Under the Component Services mmc you can manage the permissions for your PC My computer, or you can manage individual objects. Start-run-dcomcnfg (This will get you into the MMC.) - Aaron Tesch -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, January 20, 2005 4:06 PM To: [EMAIL PROTECTED]; perl-win32-users@listserv.ActiveState.com Subject: RE: Win32::OLE-GetActiveObject not working! Richard, I've been having similar difficulty using Win32::OLE with Internet Explorer recently. I wrote code that worked a month ago that doesn't work today. Perl simply can't get an OLE connection to Internet Explorer anymore, even though I can still connect to Excel, etc. Something must have changed in Windows, but I haven't been able to find any related information on the net. Mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Richard Grant Sent: Thursday, January 20, 2005 3:54 PM To: perl-win32-users@listserv.ActiveState.com Subject: RE: Win32::OLE-GetActiveObject not working! I could be wrong, but I don't think iTunes is an OLE Object which could be causing your troubles. Isn't OLE Automation just a layer on COM targeted toward scripting and VB in particular? It's a shame that it doesn't have a direct Perl API. Dunno, but I can do virtually everything with it using Win32::OLE, just this function seems to be acting odd. And it seems to be something that is part of a recent pattern that has root in the RPC layer. Richard ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ** The information contained in this message, including attachments, may contain privileged or confidential information that is intended to be delivered only to the person identified above. If you are not the intended recipient, or the person responsible for delivering this message to the intended recipient, ALLTEL requests that you immediately notify the sender and asks that you do not read the message or its attachments, and that you delete them without copying or sending them to anyone else. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs