OLE automation for MS Publisher
Using MS Publisher XP(2002), I was able to create a COM object and build a document! Apparently, previous Publisher versions did not operate on the COM standard. So far, I have managed to create a new document and open an existing .pub document, add pages at a designated position, add graphics to the page, and print the document out to a postscript file. Unfortunately, the most necessary thing, adding TextBoxes and inserting text, remains a mystery. I can't seem to transpose the VBA samples to the Perl equivalent. I am hoping someone on this list is better versed in the translation process. Here is the code snippet I am trying to translate to Perl. Help is much appreciated: VBA Code #1 (Creates the textbox): Set shpTextBox = ActiveDocument.Pages(1).Shapes.AddTextBox _ (Orientation:=pbTextOrientationHorizontal, _ Left:=144, Top:=144, _ Width:=72, Height:=18) VBA Code #2 (Places the text in the textbox and formats it): With ActiveDocument.Pages(1).Shapes(1).TextFrame.TextRange .Text = My Text With .Font .Bold = msoTrue .Size = 25 .Name = Algerian End With End With Thanks in advance for any help you can offer. Brad Smith ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Where am I going wrong with OLE and MS Word?
I have written a little app, where I would like to dynamically create a directory of resource providers, using Perl OLE and Word10. I would like the directory to contain: 1. A full page color graphic 2. Table of Contents 3. Contents: each resource provider listed on a page, separated by a page break. Each of these aspects I have successfully performed, individually. Where I am having my problems is in setting ranges for different formatting. For instance, the first page, the cover art should bleed to the edges. Then, a page break, then the Table of Contents, with 1 borders all the way around, page break, followed by the resource provider listings, each separated by a page break and formatted w/ 1 borders. I begin by using 'PageSetup' to set all margins to 0 (for full bleed). Then, I add the InlineShape to the first page. Everything works to that point. Now, I would like to reset the page borders to 1 all around and begin adding the Table of Contents and other text. Unfortunately, every time I adjust the PageSetup parameters, ALL the margins are reset, negating the 0 margins I had established for the cover art. I have read every archived email re: OLE and Word, combed my Office Developer's Guide book (VBA), searched Google for anything available, but the examples I have found do not address multiple page margins within a single document. Below is the code I have written so far. Is there anyone out there who has fond experiences with OLE automation of Word who can help me through this? Thanks in advance. use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; my($outputFile) = c:/check_this_file.doc; my($WordApp) = Win32::OLE - new('Word.Application', 'Quit'); $WordApp- {Visible} = 1; $WordApp - Documents - Add; $PageSetup=$WordApp-ActiveDocument-PageSetup; $PageSetup - {LeftMargin} = $WordApp - InchesToPoints(0); $PageSetup - {RightMargin} = $WordApp - InchesToPoints(0); $PageSetup - {TopMargin} = $WordApp - InchesToPoints(0); $PageSetup - {BottomMargin}= $WordApp - InchesToPoints(0); $coverart=c:/find-out_directory_cover.jpg; $InsertCover=$WordApp-Selection-InlineShapes- AddPicture({FileName=$coverart}); $InsertCover=$WordApp-Selection- InsertBreak({Type=wdPageBreak}); $PageSetup2=$WordApp-ActiveDocument-PageSetup; $PageSetup2 - {LeftMargin} = $WordApp - InchesToPoints(0.75); $PageSetup2 - {RightMargin} = $WordApp - InchesToPoints(0.75); $PageSetup2 - {TopMargin} = $WordApp - InchesToPoints(0.75); $PageSetup2 - {BottomMargin}= $WordApp - InchesToPoints(0.75); $WordApp-Selection-Font-{Size} = '12'; $WordApp-Selection-TypeText( Let's try some text in here to see what happens. ); $WordApp-ActiveDocument-SaveAs({FileName=$outputFile, FileFormat=wdFormatDocument}); $WordApp-ActiveDocument-Close(); $WordApp-Quit(); Brad Smith ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Quirky behavior with for loop
I have spent a good part of today trying to figure out a very simple situation where there are nested for loops. Normally, I have not had problems, but, for some reason, with this tertiary level loop, Perl decides it just doesn't exist. My abridged code is below. What am I doing wrong, please? I can't see it. The strangest part of this whole dilemma is that I can test the variable for their content just before calling the last two 'for' loops, seeing that their values are as expected, but then the innermost for loop fails. code below foreach $i (1..scalar(@question)) { if ($question_type[$i] eq columnar_chart) { @names=split (/\|/, $question_answers[$i]); $columns=scalar(@names); $these_rows=$question_values[$i]; print qq~ abridged for emailing ~; $column_width=sprintf(%.1d,100/$columns); foreach $k (0..($columns)-1) { print qq~ td align=center width=$column_width%font face=Arial size=2 color=#33$names[$k]/font/td ~; } foreach $fg (0..($these_rows)-1) { print We get to the outer loopbr; print tr; my $inner_counter=1; foreach $rt (0..($columns)-1) { print We get to the inner loopbr; $columnar_chart_value=value_.$i._.$inner_counter._.$counter; print qq~ td width=$column_width\%p align=centerinput type=text size=15 name=$columnar_chart_value/td ~; $inner_counter++; } print /tr; } } } } code above Thanks in advance. Brad Smith ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
PerlApp
I would like to use PerlApp to create a freestanding web-based application. So far, when the app is started, it uses Win32::OLE to open a browser window (MSIE), and pass it the first page, a frames page named main.html. Now, MSIE serves as my application window. I would like to be able to click links in the browser window, which would make a call to my_app.exe, and the my_app.exe would send back the corresponding information to the browser window. Right now, though, I can't seem to get it to work, since the web browser window wants to save/open the .exe from the hyperlink. I worried that this would happen in certain cases, like those people who have auto-downloaders installed, but I did not expect it not to work at this primary point. So, in the browser window, the hyperlink URL would read: a href=my_app.exe?command=do_this where 'my_App.exe' is the application I created using PerlApp, and 'coomand=do_this' is the argument I am passing. Is it just a syntax in the way I am passing the arguments? Thanks in advance for your help. Brad Smith ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Pipe to ps2pdf
I am trying to write a script that will pipe my postscript file to ps2pdf (part of Ghostscript), but I am having an impossible time. Does anyone who has implemented ghostscript have a code snippet that demonstrates how to pipe the .ps data to ps2pdf? Thanks in advance, Brad Smith [EMAIL PROTECTED] ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs