2.9 dp4 microsoft scripting (using word or excel)

runrev at animabit.de runrev at animabit.de
Mon Feb 25 12:07:04 EST 2008


Hello 

just tested the new 

do tvbscript as "vbscript"

syntax in 2.9 beta dp4 for writing from runrev into word. It workes fine.
local tVBScript
put "Dim Word" & return after tVBScript
put "Set Word = CreateObject(" & quote & "Word.Application" & quote & ")" & return after tVBScript
put "Word.Visible=1" & return after tVBScript
put "Word.Documents.Add()" & return after tVBScript
put "'Word.Selection.Font.Bold=" & quote & "1" & quote & return after tVBScript
put "Word.Selection.Font.Name=" & quote & "Arial" & quote & return after tVBScript
put "Word.Selection.TypeText(" & quote & "Hello Word" & quote & ")" & return after tVBScript
put "Word.Selection.InsertParagraph()" & return after tVBScript
put "Word.Selection.MoveDown()" & return after tVBScript
put "Word.Selection.InsertParagraph()" & return after tVBScript
put "Word.ActiveDocument.SaveAs(" & quote & "C:/newtest.doc" & quote & ")" & return after tVBScript
put tVBScript
do tVBScript as "vbscript"
---------------------------------------------
Does anyone know a trick to use the Word-Object after the vbscript has ended and runrev got the result of vbscript? Could runrev get the Word-ID as result of the createobject syntax and use it later again? I assume this wouldn't be possible, but it would be fine if this could have be done.

The same can be used with excel if you transfer the attached perl program with the -> style into point notation as I did above with word 
Regards, Franz 
Mit freundlichen Grüßen
Franz Böhmisch

boehmisch at animabit.de
http://www.animabit.de
GF Animabit Multimedia Software GmbH
Am Sonnenhang 22
D-94136 Thyrnau
Tel +49 (0)8501-8538
Fax +49 (0)8501-8537


Perl:
use Win32::OLE;
# grab the numbers
@numbers = qw(1 2 3 4 5);
# create the automation object
Win32::OLE::CreateObject("Excel.Application", $xl) || die "CreateObject: $!";
# show it and add a new workbook
$xl->{Visible} = 1;
$xl->Workbooks->Add();
# start at the top left
$col = "A"; $row = 1;
foreach $num (@numbers) {
chomp($num);
$cell = sprintf("%s%d", $col, $row++);
# add it to Excel
$xl->Range($cell)->{Value}  = $num;
}


# OLE-Programmierung mit Perl
use Win32::OLE;
$app = Win32::OLE->new('Word.Application', 'Quit') || 
  die "Problem mit WinWord: $!";
$app->{'Visible'}=1;
$worksheet = $app->Documents->Add();
$app->Selection->Style->{wdStyleHeading3} = 1;
$app->Selection->Font->{Bold} = 1;
$app->Selection->Font->{Name} = "Arial";
$app->Selection->Font->{Size} = 24;
$stil = $app->Selection->Font->{Name};
$app->Selection->TypeText("Hallo Jakob. Word schreibt von selbst ...");
$app->Selection->InsertParagraph();
$app->Selection->MoveDown();
$app->Selection->TypeText("Schriftstil ist $stil");
$app->Selection->InsertParagraph();
$app->Selection->MoveDown();
$app->Selection->InlineShapes->AddPicture("d:\\test.jpg");
$app->Selection->InsertParagraph();
$app->Selection->MoveDown();
$app->Selection->Style->{wdStyleNormal} = 1;
$app->Selection->Font->{Size} = 12;
$app->Selection->TypeText("Viel Freude bei Winword...");
$app->ActiveDocument->SaveAs("C:/animabit/newtest.doc");



More information about the use-livecode mailing list