S
Sol Apache
In September last year Jay Freeman provided this macro for Sean which is
just about perfect for my needs for putting a picture into a cell in a
header (actually six different pictures into 6 cells):
Dim oRng As Range
On Error Resume Next
ActiveDocument.CustomDocumentProperties.Add _
Name:="ClientLogPath", _
LinkToContent:=False, Value:="", _
Type:=msoPropertyTypeString
On Error GoTo 0
With Dialogs(wdDialogInsertPicture)
If .Display Then
'Populate the DocProperty with file path
ActiveDocument.CustomDocumentProperties( _
"ClientLogPath").Value = _
WordBasic.FilenameInfo$(.Name, 1)
Set oRng = ActiveDocument.Sections(1) _
.Headers(wdHeaderFooterPrimary).Range _
.Tables(1).Cell(1, 2).Range
' The next line has nothing to do with the Range!
'Selection.Collapse Direction:=wdCollapseStart
ActiveDocument.InlineShapes.AddPicture Range:=oRng, _
FileName:=ActiveDocument.CustomDocumentProperties( _
"ClientLogPath").Value
End If
End With
I have two solvable problems with this.
1. I would like to specify an actual folder name rather than ³ClientLogPath²
which opens to the last directory I have opened (or to the default one if
this macro is run for the first time). I have tried putting in the pathname
but the macro ignores this and opens to my last folder. Where do I put the
specific pathname? Or how do I change the macro to achieve this?
2. I would like to replace any picture which may already be in the cell
rather than adding the picture to the left of it. How do I select a picture,
if there is one, and have it replaced?
The unsolvable problem is that I had set the table to allow spacing between
cells. When putting in the picture Word fits the picture proportionately
inline with text but it overlaps the bottom margin. This is perhaps a Word
bug and I have redrawn my table with tiny margin cells between each picture
cell.
Finally, at the moment on my Mac the macro puts the picture proportionately
inline with text, but will this automatically work on the PCs on which the
template will be used or does there need to be a specific mention of inline
with text within the macro?
Thanks for any help and thanks very much Jay for this excellent macro.
just about perfect for my needs for putting a picture into a cell in a
header (actually six different pictures into 6 cells):
Dim oRng As Range
On Error Resume Next
ActiveDocument.CustomDocumentProperties.Add _
Name:="ClientLogPath", _
LinkToContent:=False, Value:="", _
Type:=msoPropertyTypeString
On Error GoTo 0
With Dialogs(wdDialogInsertPicture)
If .Display Then
'Populate the DocProperty with file path
ActiveDocument.CustomDocumentProperties( _
"ClientLogPath").Value = _
WordBasic.FilenameInfo$(.Name, 1)
Set oRng = ActiveDocument.Sections(1) _
.Headers(wdHeaderFooterPrimary).Range _
.Tables(1).Cell(1, 2).Range
' The next line has nothing to do with the Range!
'Selection.Collapse Direction:=wdCollapseStart
ActiveDocument.InlineShapes.AddPicture Range:=oRng, _
FileName:=ActiveDocument.CustomDocumentProperties( _
"ClientLogPath").Value
End If
End With
I have two solvable problems with this.
1. I would like to specify an actual folder name rather than ³ClientLogPath²
which opens to the last directory I have opened (or to the default one if
this macro is run for the first time). I have tried putting in the pathname
but the macro ignores this and opens to my last folder. Where do I put the
specific pathname? Or how do I change the macro to achieve this?
2. I would like to replace any picture which may already be in the cell
rather than adding the picture to the left of it. How do I select a picture,
if there is one, and have it replaced?
The unsolvable problem is that I had set the table to allow spacing between
cells. When putting in the picture Word fits the picture proportionately
inline with text but it overlaps the bottom margin. This is perhaps a Word
bug and I have redrawn my table with tiny margin cells between each picture
cell.
Finally, at the moment on my Mac the macro puts the picture proportionately
inline with text, but will this automatically work on the PCs on which the
template will be used or does there need to be a specific mention of inline
with text within the macro?
Thanks for any help and thanks very much Jay for this excellent macro.