Re: Win32::OLE and Excel, Word, Access etc.
On Tue, 7 Jan 2003, Jack wrote: > - Original Message - > From: "Carl Jolley" <[EMAIL PROTECTED]> > To: "Jack" <[EMAIL PROTECTED]> > Cc: "Perl-Win32-Users" <[EMAIL PROTECTED]> > Sent: Tuesday, January 07, 2003 3:02 PM > Subject: Re: Win32::OLE and Excel, Word, Access etc. > > > > On Mon, 6 Jan 2003, Jack wrote: > > > > > I see many questions on this list asking about using Win32::OLE in > interacting > > > with these (and other MS programs). Could someone point me to either a book > or > > > online documentation which reveals all the methods one can use with each > > > program? > > All these proteriees/methods are documented in the respective program's > > typelib. > > > > If you don't know what a typelib is, you need to find out before you > > spend a lot of time trying to write programs using the Win32::OLE module. > > I have no idea what a typelib is; so are you saying my time is better spent on > something else? > No, just that finding out about typelib's will make it a lot easier to use Win32::OLE. The new releases of perl come with a typelib broswer. In addition if you have any of the MS software development tools often they will provide a mechanism to browse typelibs. Typelibs basically tell COM what properties and methods a given program is providing for OLE access. For example MS Word, excel and Access each have their own separate typelib that complely specifies how that program can interact with COM/OLE. [EMAIL PROTECTED] All opinions are my own and not necessarily those of my employer ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE and Excel, Word, Access etc.
- Original Message - From: "Carl Jolley" <[EMAIL PROTECTED]> To: "Jack" <[EMAIL PROTECTED]> Cc: "Perl-Win32-Users" <[EMAIL PROTECTED]> Sent: Tuesday, January 07, 2003 3:02 PM Subject: Re: Win32::OLE and Excel, Word, Access etc. > On Mon, 6 Jan 2003, Jack wrote: > > > I see many questions on this list asking about using Win32::OLE in interacting > > with these (and other MS programs). Could someone point me to either a book or > > online documentation which reveals all the methods one can use with each > > program? > All these proteriees/methods are documented in the respective program's > typelib. > > If you don't know what a typelib is, you need to find out before you > spend a lot of time trying to write programs using the Win32::OLE module. I have no idea what a typelib is; so are you saying my time is better spent on something else? Jack ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE and Excel, Word, Access etc.
On Mon, 6 Jan 2003, Jack wrote: > I see many questions on this list asking about using Win32::OLE in interacting > with these (and other MS programs). Could someone point me to either a book or > online documentation which reveals all the methods one can use with each > program? > > For example from a recent post: > > $excel -> {DisplayAlerts} = 0; > $book -> SaveAs ("$pwd\\spreadsheet.xls"); > > Where would one find out what the DisplayAlerts variable is? Where is SaveAs > documented? > All these proteriees/methods are documented in the respective program's typelib. If you don't know what a typelib is, you need to find out before you spend a lot of time trying to write programs using the Win32::OLE module. [EMAIL PROTECTED] All opinions are my own and not necessarily those of my employer ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::OLE and Excel, Word, Access etc.
> I see many questions on this list asking about using > Win32::OLE in interacting > with these (and other MS programs). Could someone point me to > either a book or > online documentation which reveals all the methods one can > use with each > program? > > For example from a recent post: > > $excel -> {DisplayAlerts} = 0; > $book -> SaveAs ("$pwd\\spreadsheet.xls"); > > Where would one find out what the DisplayAlerts variable is? > Where is SaveAs > documented? I'm going through that at the moment. I have gleaned all my information from this list, the newsgroups, asking questions, and general web trawling. I have one link that you might find useful... http://perlmonks.org/index.pl?node_id=153486 What I have learnt, so far, is this: 1. Start Excel like this: eval {$excel = Win32::OLE->GetActiveObject('Excel.Application')}; die "WARNING! Excel not installed" if $@; unless (defined $excel) { $excel = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or die "ERROR, cannot start Excel"; } 2. You can load (Open) a spreadsheet from the directory that your script is run from without specifying the full path. $book = $excel -> Workbooks -> Open ($filename) 3. If you are modifying an existing spreadsheet, and want to save the changes to the same file name, use the Save command, and you will not get any 'overwrite?' prompts from Excel. $book -> Save; 4. You will have to use the SaveAs command to save the spreadsheet with a different name to that when opened. If the save-name exists, you will get an 'Overwrite?' prompt from Excel. You can stop this prompt by using this command: $excel -> {DisplayAlerts} = 0; This command can't be used just anywhere, though. You must have opened a spreadsheet first. The safest way is to use this command directly before the SaveAs command. 5. When using the SaveAs command, you will have to provide the full path to save the spreadsheet, with the slashes going the right way. As I load and save in the directory that my script runs from, I have used the following: use Cwd; our $pwd = cwd; $pwd =~ s!/!\\!g; This allows you to save a spreadsheet called $sheet, like this: $book -> SaveAs ("$pwd\\$sheet"); 6. If you open a workbook with several sheets, then you need to use the following commands to select and activate the sheet that you want to modify. This will open and activate the 4th sheet: $active_sheet = $book -> Worksheets (4); $active_sheet -> Activate(); This will open a sheet called "Sheet 4": $active_sheet = $book -> Worksheets ("Sheet 4"); $active_sheet -> Activate(); 7. When you've finished with your spreadsheet, saved and closed it, you may want to end Excel, too. If you have activated a sheet in step 6, you MUST deactivate it, otherwise the Excel process will not terminate properly. I haven't found a deactivate command, so I used: undef $active_sheet; That's all I can think of right now. The tutorial I mentioned is very good, and should help out with everything else. R. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE and Excel, Word, Access etc.
Jack wrote: > I see many questions on this list asking about using Win32::OLE in interacting > with these (and other MS programs). Could someone point me to either a book or > online documentation which reveals all the methods one can use with each [snips] Jack -- One quick answer is there is vb reference comes with, say, ms word, for macro creation. Also, ole browser (dhtml app) comes with AS install, on my machine at: C:\Perl\html\site\lib\Win32\OLE\Browser\Browser.html. On my machine, needs IE to run. Good luck! -- Michael Higgins ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Win32::OLE and Excel, Word, Access etc.
I see many questions on this list asking about using Win32::OLE in interacting with these (and other MS programs). Could someone point me to either a book or online documentation which reveals all the methods one can use with each program? For example from a recent post: $excel -> {DisplayAlerts} = 0; $book -> SaveAs ("$pwd\\spreadsheet.xls"); Where would one find out what the DisplayAlerts variable is? Where is SaveAs documented? Jack ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs