Results 1 to 14 of 14
  1. #1
    New Lounger
    Join Date
    Apr 2003
    Location
    Illinois, USA
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    W2k: Insert Scanned Signature Behind Text (Word2000)

    I'm having some difficulty under Word2000 inserting my pre-scanned signature, then moving it to behind the text, within a macro. I've tried two different approaches:

    Insert | Picture | From file {name of file}

    which does just fine importing a 300dpi graphic. However, the graphic is NOT selected as the current selection (a really stupid design choice), so I can't move it behind the text (so that it doesn't change the spacing between the closing and the signature block text) within a macro; instead, I have to manually select the graphic and move it behind the text using the command. I cannot find a way to force Word2000 to back up and select what it just inserted without manual selection.

    The other approach is to insert an object | From file {name of file} . Although this does insert the file and leave it selected, it automatically resets resolution to 96dpi, requiring use of "format picture" to change size to 32% and move it behind. And it's incredibly slow, because Word2000 opens a Photo Editor process in the background to import the jpg (which, by the way, is NOT the default action under my setup of Windows98, because the default viewer is a different program).

    And thus my question:

    The obviously preferable method is Insert | Picture | From file {name of file} . How can I force Word2000 to select that graphic I've just inserted within a macro?

    By the way, I've tried this after converting the graphic to a number of other formats, including a GIF with transparency, PNG (with and without transparency), TIFF, and BMP, with varying problems. The bottom line is that nothing I've tried is satisfactory.

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    Often you can set an object reference to an object you are adding (as you are adding it) - this provides an easy way to refer to it later in the code. But it doesn't seem to work with AddPicture (at least not in Word 2002, which by the way inserts a picture as an inline shape).

    Here's a workaround that enables you to select the newly-added picture via code - the added picture becomes the last item in the InlineShapes collection, so you can use the Count property of the InlineShapes collection to provide an index by which you can address the picture:

    <pre> Dim lngInlineShapesCt As Long
    Selection.InlineShapes.AddPicture _
    FileName:="[path]" _
    , LinkToFile:=False, SaveWithDocument:=True
    lngInlineShapesCt = ActiveDocument.InlineShapes.Count
    ActiveDocument.InlineShapes(lngInlineShapesCt).Sel ect
    </pre>

    If your version of Word is defaulting to insert the picture as a Shape, then substitute Shapes for InlineShapes in the code.

    Gary

  3. #3
    New Lounger
    Join Date
    Apr 2003
    Location
    Illinois, USA
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    Well, almost; this was helpful. There remains one little problem: one cannot move an InlineShape behind the current text. However, one can convert it to a shape and then do so. It looks a bit wonky (technical term there) while the macro is actually running, but it works.

    Here's the code, stripped out to be generic (so it could apply to, say, an attorney's watermark that a document is privileged, not just a signature):

    Sub InsertGraphicBehind()
    '
    ' Macro written 3421 by CEP
    ' Purpose: insert graphic file, such as a prescanned signature, into document without changing vertical spacing
    '
    ' Define counter variable
    Dim lngInlineShapesCt As Long
    ' Insert graphic file as inline shape
    Selection.InlineShapes.AddPicture FileName:="[FullPathName]", LinkToFile:=False, SaveWithDocument:=True
    lngInlineShapesCt = ActiveDocument.InlineShapes.Count
    ' Select the graphic
    ActiveDocument.InlineShapes(lngInlineShapesCt).Sel ect
    ' Convert from InlineShape to Shape, because InlineShapes cannot move behind text
    ActiveDocument.InlineShapes(lngInlineShapesCt).Con vertToShape
    ' Move behind text (using minimal changes)
    Selection.ShapeRange.RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn
    Selection.ShapeRange.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
    Selection.ShapeRange.Left = InchesToPoints(0)
    Selection.ShapeRange.Top = InchesToPoints(0)
    Selection.ShapeRange.LockAnchor = False
    Selection.ShapeRange.WrapFormat.AllowOverlap = True
    Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
    Selection.ShapeRange.WrapFormat.Type = 3
    Selection.ShapeRange.ZOrder msoSendBehindText
    ' Leave selection on in case it needs to be moved manually
    End Sub

    Note three things in this macro:
    (1) It has only been thoroughly tested in Word2000; it may need adaptation elsewhere.
    (2) One cannot simply use the FormatPicture | Order | SendBehindText method in the macro that one could use if right-clicking on the selected graphic. An apparent bug actually sends the graphic in FRONT of the text when a recorded macro is replayed! This appears to be because the command changes the order without changing the wrapping to allow the stuff that is supposedly now in front (the text) to actually overprint. This is a bug, not a feature.
    (3) Nonetheless, it is absolutely critical that the zOrder setting (last line of actual code) call the msoSendBehindText method, not just the numeric code 4 (as one would get trying to record the macro). For whatever reason, even though when recording the macro it does move the graphic behind the text, when playing back the macro it moves the graphic in front! Again, this is a bug, not a feature.

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    Working with shapes programatically definitely has its quirks - sounds like are getting a handle on it though. One thing you could add to the code to perhaps reduce the wonkiness is to put an "Application.ScreenUpdating = False" statement at the beginning of the procedure (and set it back to True at the end of the procedure).

    Gary

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    Might something like this be easier? See <post#=245001>post 245001</post#>.

  6. #6
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    I would recommend doing it once without code and then save it as an autotext entry in your Normal.dot template. Then you won't need a macro to do the insert whenever you need to get your signature into the file.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  7. #7
    New Lounger
    Join Date
    Apr 2003
    Location
    Illinois, USA
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    Autotext is not acceptable for security reasons--and the formatting of the graphic as "behind the text" doesn't persist if Word2000 is shut down anyway. (Other versions may, of course, be different.)

  8. #8
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    To maintain security - are you linking the graphic in and not storing a copy in the file? If so then perhaps you could play with field codes instead of the graphic directly.

    What other security considerations are you referring to?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  9. #9
    New Lounger
    Join Date
    Apr 2003
    Location
    Illinois, USA
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    Autotext functions interfere with certain other software that I run in investigating internet piracy. They are also a serious problem for those of us who write in more than one language in the same document. And I just plain don't like them, primarily because the stupid defaults cause serious trouble in writing legal documents. (In Word97, it wouldn't have worked anyway--I had tried that.)

  10. #10
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    I am intrigued that you have so many problems with autotext. I can imagine some of the problems you describe arising with autocorrect entries but I haven't encountered similar problems with autotext. Are you sure you are not getting the two methods confused - they are quite different?

    If it is autotext and it didn't work in Word 97, then it isn't worth trying in Word 2000 as nothing changed on that front with Word 2000.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  11. #11
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Phoenix, Arizona, USA
    Posts
    205
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    Andrew, I am replying to you because I have something similar I want to do with a watermark but I have been unable to save the watermark as autotext. I used WordArt to create the word "DRAFT" and I have it positioned and shaded just the right way. I asked if anyone had a macro that would work with this and the response I got for a macro did not work. Someone suggested saving it as autotext but I am unable to select the WordArt so I can do this. I have attached my document so you can see what I am doing. If you can help me with this, I would be much obliged.
    Attached Files Attached Files

  12. #12
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    Here is a tidied up exerpt from a macro of mine, it shows how to create a WordArt object in a macro, you should be able to modify it to do what you need.

    Public Sub WMark()
    Dim shpWordArt As Shape
    Dim strWMarkText As String
    Dim strFontName As String
    Dim sngAngle As Single
    Dim sngWidth As Single

    strWMarkText = "DRAFT"
    strFontName = "Times New Roman"
    sngAngle = 45
    sngWidth = 200

    With ActiveDocument.Sections(1).Headers(wdHeaderFooterP rimary)
    Set shpWordArt = .Shapes.AddTextEffect(msoTextEffect1, strWMarkText, strFontName, 36#, msoFalse, msoFalse, 1, 1, .Range)
    End With

    With shpWordArt
    .Width = sngWidth
    .Rotation = sngAngle
    .RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
    .RelativeVerticalPosition = wdRelativeVerticalPositionMargin
    .Left = wdShapeCenter
    .Top = wdShapeCenter
    End With


    End Sub

    StuartR

  13. #13
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    Hi Jan:
    I had no trouble creating an autotext entry from your attachment.
    1. Open the document.
    2. View Header/Footer
    3. Click on the "Draft" (just near the cross on the "F" was a good spot). The picture toolbar appears & the graphic is selected.
    4. Press Alt+F3 & give it a name. (or use a template other than normal, if you prefer).

    Your watermark should be available.

    I turned your watermark document into a template. If you type draft & press F3, the watermark appears as you formatted it.

    I have to look for non macro ways as I'm VBA challenged. <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    Attached Files Attached Files

  14. #14
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Phoenix, Arizona, USA
    Posts
    205
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: W2k: Insert Scanned Signature Behind Text (Word2000)

    Phil, thank you so much for saving this as autotext and then as a template. It works beautifully. I am VBA challenged, as well. I will go into a copy of my original document and try selecting the WordArt again to see if I can get it to work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •