[Tutor] Planning to write Python scripts and programs (migrating a Basic macro)

McCarney, James Alexander James.Alexander.McCarney@Cognicase.com
Wed, 16 Jan 2002 12:23:26 -0500


Hi Tutorfolk!

Thanks for your information of the other day. I am progressing through the
various tools out there, such as Learning Python book, and the various
brilliant
tutorials.

I have a perfect candidate (maybe?) for my first real-life Py project, and I
would
appreciate your comments (if you would be so kind).

I have a Word (Basic) macro that I run against images in docs that I create
to resize them. 
I wonder if I could either rewrite it totally in Py or have Py open the
document file, 
execute the macro, save the file, and quit.

The platform I run under is Windows 2000, the Microsoft Word version is
2000, and I have upgraded
to Python 2.2.

Possibly the quick/dirty way is to have Py open the doc run the Basic macro
and close?

To begin to attempt the Py (pseudo)code:

def OpenDoc(doc_filename):
	import Some Module # don't know
	???			# utter Python confusion
	???
	???

I will try to work on this. This mail is sort of my brain-cramp output now
But if someone could point me in the direction to start on my Confucian
1000-mile
journey... I would be grateful.

The Basic code is this (shield your eyes or snip it out now, cos it's not
Py!!!)

Sub ReduceTo50()
'
' ReduceTo50 Macro
' Macro created 09/12/01 by James Alexander McCarney
'
Dim lngX As Long
On Error Resume Next 'Important or the code may puke

For lngX = 1 To ActiveDocument.InlineShapes.Count
    ActiveDocument.InlineShapes(lngX).Select
    If (ActiveDocument.InlineShapes(lngX).Type = wdInlineShapeLinkedPicture
Or ActiveDocument.InlineShapes(lngX).Type = wdInlineShapePicture) Then
        Selection.InlineShapes(1).ScaleHeight = 40  'Set the height to
whatever you want 50, 40, 30 (for smaller pix)
        Selection.InlineShapes(1).ScaleWidth = 40   'Set the height to
whatever you want 50, 40, 30 (for smaller pix)

    End If

Next lngX

End Sub




James Alexander McCarney (450) 928-3386 x2262
Cognicase - M3i Systems, 1111 Saint-Charles Avenue West
11th Floor, East Tower, Longueuil, Quebec, J4K 5G4 Canada

http://www.m3isystems.com
mailto:James.Alexander.McCarney@Cognicase.com