[AccessD] Word Automation

Jürgen Welz jwelz at hotmail.com
Sun Dec 11 22:21:54 CST 2005


Bryan:

Thanks for the tips.  The macro recorder got me to the inline shapes 
collection.  Then I recorded another macro after selecting the image.  
Converting to shape appears to give me accessibility to a few more 
attributes.  I had set the lock aspect ratio to true, and this appears not 
to have an effect.  The logos have different text and lengths but should be 
0.35" high so I stored the .Height before and after resizing in a variable 
and applied the same multiplier to the length.

User documents will generally be only one page in length, but, some may be 2 
or more pages so my existing templates use the graphic at the top of the 
first page and the smaller one on the primary page header (suppressed on the 
first page).  Both the first page footer and primary page footer are used, 
the first page listing office city with phone & fax and the subsequent pages 
with city only.  Placing the logo on the first page, not in a header ensures 
that the color has proper saturation when used in presentations and emailed 
copies.  Placing the smaller graphic in the primary header, starting on the 
2nd page, ensures that, although the color isn't entirely accurate, it is 
not seen as big or as often as the first page logo and it will be present 
regardless of how many pages in the final document.

I have accessed the headers and footers through code but always saved my 
templates with 2 pages visible so I could easily access the first page and 
primary headers & footers with automation due to the different content of 
1st and subseqent headers and footers and deleted the Ctrl-Enter so as to 
show the users the first page of the document for them to begin filling in 
the document .  Even though most documents are typically a single page, as 
soon as the document flows to a subsequent page, the headers and footer are 
correct.  With the upgrade from 2000 to 2003, the automation code I wrote 
for deleting the Ctrl-Enter broke so I am now looking at leaving the blank 
templates with only the one page showing.  I haven't yet completed sorting 
out the 'window', 'pane' and use of wdSeekFirstPageFooter and 
wdSeekPrimaryPageFooter and it seems the seek won't find the Primary unless 
a subsequent page is displayed.  Any hints?

There is no advantage to building a Word Wizard.  Documents are generated 
from something like a Bid or Project record (Or contact, employee or company 
record).  The record form pops up modal form (with a document list 
displaying all related documents) which shows the responsible office, 
division, user, date, a list of record related recipients from which to 
select (or add) and the form has a drop down list of all relevant document 
types that a user might wish to create for that kind of record.  When a user 
selects a document type, the document list is filtered to display exisiting 
related documents of the selected type and a 'create new' button becomes 
enabled.  The user may change the office/division/user or other aspects of 
the document to be generated from this modal form by selecting from a combo 
box.  Running the document creation code from the record defines a default 
save location (the list is populated by Dir, not table entries) and the 
office, division and other related default information is correct without 
user intervention (so prone to error) well  over 99% of the time, yet can be 
changed when the user needs to do so.  Using a Word wizard forces the user 
to make too many decisions.

Ciao
Jürgen Welz
Edmonton, Alberta
jwelz at hotmail.com





>From: "Bryan Carbonnell" <carbonnb at sympatico.ca>
>Reply-To: Access Developers discussion and problem 
>solving<accessd at databaseadvisors.com>
>To: Access Developers discussion and problem 
>solving<accessd at databaseadvisors.com>
>Subject: Re: [AccessD] Word Automation
>Date: Sun, 11 Dec 2005 11:13:13 -0500
>MIME-Version: 1.0
>X-Originating-IP: [67.68.49.67]
>X-Originating-Email: [carbonnb at sympatico.ca]
>Received: from databaseadvisors.com ([209.135.140.44]) by 
>bay0-mc12-f10.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Sun, 
>11 Dec 2005 08:18:37 -0800
>Received: from databaseadvisors.com (databaseadvisors.com 
>[209.135.140.44])by databaseadvisors.com (8.11.6/8.11.6) with ESMTP id 
>jBBGH4J24480;Sun, 11 Dec 2005 10:17:04 -0600
>Received: from 
>BAYC1-PASMTP02.bayc1.hotmail.com(bayc1-pasmtp02.bayc1.hotmail.com 
>[65.54.191.162])by databaseadvisors.com (8.11.6/8.11.6) with ESMTP id 
>jBBGDPJ23700for <accessd at databaseadvisors.com>; Sun, 11 Dec 2005 10:13:26 
>-0600
>Received: from [192.168.1.100] ([67.68.49.67]) 
>byBAYC1-PASMTP02.bayc1.hotmail.com over TLS secured channel withMicrosoft 
>SMTPSVC(6.0.3790.1830); Sun, 11 Dec 2005 08:13:17 -0800
>X-Message-Info: LGjzam7y+LsNmlxFf3VQc7DaIDHB23LBzw38214Ej+o=
>Organization: None that  I have ever noticed! :-)
>Priority: normal
>References: <s399b523.046 at cactus.dk>
>X-mailer: Pegasus Mail for Windows (4.30 public beta 1)
>X-OriginalArrivalTime: 11 Dec 2005 16:13:18.0192 
>(UTC)FILETIME=[CC456F00:01C5FE6D]
>X-MIME-Autoconverted: from Quoted-printable to 8bit by databaseadvisors.com 
>idjBBGDPJ23700
>X-BeenThere: accessd at databaseadvisors.com
>X-Mailman-Version: 2.1.6
>Precedence: list
>List-Id: Access Developers discussion and problem 
>solving<accessd.databaseadvisors.com>
>List-Unsubscribe: 
><http://databaseadvisors.com/mailman/listinfo/accessd>,<mailto:accessd-request at databaseadvisors.com?subject=unsubscribe>
>List-Archive: <http://databaseadvisors.com/pipermail/accessd>
>List-Post: <mailto:accessd at databaseadvisors.com>
>List-Help: <mailto:accessd-request at databaseadvisors.com?subject=help>
>List-Subscribe: 
><http://databaseadvisors.com/mailman/listinfo/accessd>,<mailto:accessd-request at databaseadvisors.com?subject=subscribe>
>Errors-To: accessd-bounces at databaseadvisors.com
>Return-Path: accessd-bounces at databaseadvisors.com
>
>Welcome Back Jürgen, If nothing else, you are making our collective
>brains hurt :-))
>
>Some comments and suggestions in-line
>
>On 9 Dec 2005 at 12:16, Jürgen Welz wrote:
>
> > Here's the question.  When I tried implemeting this last time, the
> > macro recorder in Word would record the insertion of a graphic, but I
> > could not do a thing with the graphic while the recorder was running.
> > I think that the Picture toolbar was unavailable in Access 97 and
> > 2000.  In Word 2003, I can select items on the Picture toolbar, but I
> > can't select the graphic to apply the action to the graphic.  If I
> > select the graphic before impelementing the macro recorder, it remains
> > selected, but if I select a picture toolbar button, I still cannot
> > affect the graphic.
>
>The problem with the macro recorder, in case you didn't already know,
>is that when the macro recorder is running is that a lot of mouse
>commands aren't available. You will need to use the equivilent
>keyboard commands, IF they exists. Otherwise, you will need to figure
>out how to affect the changes in VBA without the help of a recorded
>macro.
>
>Now onto the problem at hand, not being able to modify the image.
>
>To modify an image in VBA and have access to everything that is
>available in the format picture dialog box, you first need to convert
>it into a Word Shape from a Word InLine Shape.
>
>Assuming that the image you want to work with is the first image in
>the InLineShapes collection, you'd need to do something like
>
>ActiveDocument.InlineShapes(1).ConvertToShape
>
>Then you will need to set the WrapFormat Type to the wrapping format
>you want.
>
>ActiveDocument.Shapes(1).WrapFormat.Type = wdWrapTight
>
>Then you can move it using the .Top and .Left property of the Shapes
>collection
>
>ActiveDocument.Shapes(1).Top = 0
>ActiveDocument.Shapes(1).Left = 0
>
>That puts it in the top left corner of the page that the image is on.
>
>And to scale it, use scalewidth and scaleheight
>
>ActiveDocument.Shapes(1).ScaleWidth 0.37, msoTrue
>ActiveDocument.Shapes(1).ScaleHeight 0.37, msoTrue
>
>This will resize it to 37% of the original height and width relative
>to the original size.
>
>So a full snippet would look something like:
>
>Dim shp As Shape
>
>Set shp = ActiveDocument.InlineShapes(1).ConvertToShape
>
>With shp
>   .WrapFormat.Type = wdWrapTight
>   .Top = 0
>   .Left = 0
>   .ScaleWidth 0.37, msoTrue
>   .ScaleHeight 0.37, msoTrue
>End With
>
>Set shp = Nothing
>
> > I'l like to movesize the graphic to a specified location with a
> > standard height that is different for the 1st and subsequent page logo
> > and also different from the default size of the graphic when inserted.
>
>Now, to deal with the logo on the second page, the image has to start
>out on the second page. You just need to make sure that when you hit
>the line
>
>Set shp = ActiveDocument.InlineShapes(1).ConvertToShape
>
>you are dealing with the correct item in the InLineShapes collection.
>
> > I have been asked to implement a logo change immediately, but the
> > current version of a typical version is 1,736 bytes and the outlines
> > are too obviously segmented for me to manually change all the logos
> > now, only to redo it again with improved files a month from now.
>
>Here is a suggestion, and I don't know how well it will work for your
>environment, but how about creating a Word template wizard to build
>the template on the fly? You can have the user select the type of
>template they want to create, the logo they will use, etc. And in the
>wizard you can embed the image at creation time, that way when the
>logos change, you just have to update the logo and not all the
>templates.
>
>Hopefully some of this will be of help.
>
>--
>Bryan Carbonnell - carbonnb at sympatico.ca
>If you're too open-minded, your brains will fall out.





More information about the AccessD mailing list