russell13osu
01-04-2011, 10:44 AM
Hi all,
I'm in the midst of finishing some procedures that are called from a userform which should simplify repetitive manual tasks for the people in my office. All code is functioning well, but there is one small problem I can't seem to get around.
There is a file image that gets inserted into our Word documents, which are eventually translated and displayed online. When done manually, the user would insert the file, Cut, and then Paste Special as a "Picture (PNG)" in order to get the image to display correctly online. Without doing this Cut and Paste Special, our translation tool will place a faint border around the image, which is undesirable. I was able to automate this task with this code:
headingBullet = "Z:\path to my.png"
Selection.InlineShapes.AddPicture FileName:= headingBullet, LinkToFile:=False, SaveWithDocument:=True
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Cut
Selection.PasteSpecial Link:=False, DataType:=14, Placement:=wdInLine, DisplayAsIcon:=False
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoFalse
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 28.8
Selection.ShapeRange.Width = 28.8
Selection.ShapeRange.Rotation = 0#
Selection.ShapeRange.PictureFormat.Brightness = 0.5
Selection.ShapeRange.PictureFormat.Contrast = 0.5
Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic
Selection.ShapeRange.PictureFormat.CropLeft = 0#
Selection.ShapeRange.PictureFormat.CropRight = 0#
Selection.ShapeRange.PictureFormat.CropTop = 0#
Selection.ShapeRange.PictureFormat.CropBottom = 0#
The problem I'm having is that the superseding routines now require the clipboard to operate. I need to insert a file image in the same manner as above without using the clipboard. I'm pretty sure the attribute I need is the "DataType:=14." I cannot find a way to directly use this though, as it is a WdPasteDataType. I can't seem to find an enumeration list anywhere that even tells me what this DataType is. Is it simply a PNG picture?
Does anyone have insight about how I might insert this image, in the desired format, without using the clipboard (or by possibly going two items deep into the Office clipboard)?
Thanks in advance,
Bob
MS Word 2003 SP3, Office Pro 2003
I'm in the midst of finishing some procedures that are called from a userform which should simplify repetitive manual tasks for the people in my office. All code is functioning well, but there is one small problem I can't seem to get around.
There is a file image that gets inserted into our Word documents, which are eventually translated and displayed online. When done manually, the user would insert the file, Cut, and then Paste Special as a "Picture (PNG)" in order to get the image to display correctly online. Without doing this Cut and Paste Special, our translation tool will place a faint border around the image, which is undesirable. I was able to automate this task with this code:
headingBullet = "Z:\path to my.png"
Selection.InlineShapes.AddPicture FileName:= headingBullet, LinkToFile:=False, SaveWithDocument:=True
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Cut
Selection.PasteSpecial Link:=False, DataType:=14, Placement:=wdInLine, DisplayAsIcon:=False
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoFalse
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 28.8
Selection.ShapeRange.Width = 28.8
Selection.ShapeRange.Rotation = 0#
Selection.ShapeRange.PictureFormat.Brightness = 0.5
Selection.ShapeRange.PictureFormat.Contrast = 0.5
Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic
Selection.ShapeRange.PictureFormat.CropLeft = 0#
Selection.ShapeRange.PictureFormat.CropRight = 0#
Selection.ShapeRange.PictureFormat.CropTop = 0#
Selection.ShapeRange.PictureFormat.CropBottom = 0#
The problem I'm having is that the superseding routines now require the clipboard to operate. I need to insert a file image in the same manner as above without using the clipboard. I'm pretty sure the attribute I need is the "DataType:=14." I cannot find a way to directly use this though, as it is a WdPasteDataType. I can't seem to find an enumeration list anywhere that even tells me what this DataType is. Is it simply a PNG picture?
Does anyone have insight about how I might insert this image, in the desired format, without using the clipboard (or by possibly going two items deep into the Office clipboard)?
Thanks in advance,
Bob
MS Word 2003 SP3, Office Pro 2003