T
Tony Strazzeri
Hi All,
A company I work for has recently changed their Brand image. This
involves changing document fonts and layouts as well as changes to
some template code and forms.
I have written a program to adjust the template layout. This program
will also go through the template's codemodules and update amendment
history and version numbers in the template's VBA code.
The templates also have userforms, all of which have a company logo in
an image control on the form.
I would like to ALSO automate this part. I thought it would be
possible to create a reference to the control and to change the image
with the program.
However, the Picture property of the image control seems to be an OLE
container and I have been unable to work out how to drop the new image
into this container.
Does anyone know how I can do this?
Cheers
TonyS.
Below is some of the code I use to change the codemodules.
Dim myComponent As VBComponent
Const FORM_NAME = "frmDocData"
Const RELMARKER = "Private Const Relver ="
Const MODULE_NAME = "modAmendmentHistory"
Const IMAGE_CONTROL_NAME = "imgClientLogo"
Dim I
Dim strLine As String
Dim currProj As VBProject
Dim myControl As Control
Dim strNewHistory As String
Dim CurrDateStamp
CurrDateStamp = "11/08/2004"
strNewHistory = "Private Const Relver = ""2K04.11""" _
& vbCr & "Private Const ModDate = """ & CurrDateStamp &
"""" _
& vbCr & "'#" & String(82, "*") _
& vbCr & "'# Version Date Who Details" _
& vbCr & "'# ====== ========== === " & String(54,
"=") _
& vbCr & "'# 2K04.11 " & CurrDateStamp _
& " TS Branding update."
Set currProj = ActiveDocument.VBProject
'This looks for the line beginning with RELMARKER and replaces it
and
'the following five lines with the new amendment history and
version info
'The amendment history looks something like this.
'Note the actual history does not have the comment char before the
Private Const below.
'Private Const Relver = "v1.01"
'Private Const ModDate = "29/02/2003"
''#**********************************************************************************
''# Version Date Who Details
''# ====== ========== ===
======================================================
''# v1.01 25/03/2003 TS User Updates.
''# v1.00 29/02/2003 TS New Template.
' This finds the appropriate spot and updates the amendment
history
Set myComponent = currProj.VBComponents(MODULE_NAME)
With myComponent.CodeModule
For I = 1 To .CountOfLines
strLine = Trim(.Lines(I, 1))
If Left(strLine, Len(RELMARKER)) = RELMARKER Then
.DeleteLines I, 5
.InsertLines I, strNewHistory
Exit For
End If
Next I
End With
'This hopes to change the logo image on the form
Set myComponent = currProj.VBComponents(FORM_NAME)
For I = 1 To myComponent.Designer.Controls.Count
With myComponent.Designer
If .Controls(I).Name = IMAGE_CONTROL_NAME Then
Set myControl = .Controls(I)
'**************************************************************
'This is where it fails because the .Picture is an OLE object.
'**************************************************************
'**************************************************************
'**************************************************************
' Its only properties are
' name Type
' ======= ==============
' Handle OLE_HANDLE
' Height OLE_YSIZE_HIMETRIC
' hPAL OLE_HANDLE
' Type Integer
' Width OLE_XSIZE_HIMETRIC
'**************************************************************
myControl.Picture = "newLogo" ''?????
Exit For
End If
End With
Next I
A company I work for has recently changed their Brand image. This
involves changing document fonts and layouts as well as changes to
some template code and forms.
I have written a program to adjust the template layout. This program
will also go through the template's codemodules and update amendment
history and version numbers in the template's VBA code.
The templates also have userforms, all of which have a company logo in
an image control on the form.
I would like to ALSO automate this part. I thought it would be
possible to create a reference to the control and to change the image
with the program.
However, the Picture property of the image control seems to be an OLE
container and I have been unable to work out how to drop the new image
into this container.
Does anyone know how I can do this?
Cheers
TonyS.
Below is some of the code I use to change the codemodules.
Dim myComponent As VBComponent
Const FORM_NAME = "frmDocData"
Const RELMARKER = "Private Const Relver ="
Const MODULE_NAME = "modAmendmentHistory"
Const IMAGE_CONTROL_NAME = "imgClientLogo"
Dim I
Dim strLine As String
Dim currProj As VBProject
Dim myControl As Control
Dim strNewHistory As String
Dim CurrDateStamp
CurrDateStamp = "11/08/2004"
strNewHistory = "Private Const Relver = ""2K04.11""" _
& vbCr & "Private Const ModDate = """ & CurrDateStamp &
"""" _
& vbCr & "'#" & String(82, "*") _
& vbCr & "'# Version Date Who Details" _
& vbCr & "'# ====== ========== === " & String(54,
"=") _
& vbCr & "'# 2K04.11 " & CurrDateStamp _
& " TS Branding update."
Set currProj = ActiveDocument.VBProject
'This looks for the line beginning with RELMARKER and replaces it
and
'the following five lines with the new amendment history and
version info
'The amendment history looks something like this.
'Note the actual history does not have the comment char before the
Private Const below.
'Private Const Relver = "v1.01"
'Private Const ModDate = "29/02/2003"
''#**********************************************************************************
''# Version Date Who Details
''# ====== ========== ===
======================================================
''# v1.01 25/03/2003 TS User Updates.
''# v1.00 29/02/2003 TS New Template.
' This finds the appropriate spot and updates the amendment
history
Set myComponent = currProj.VBComponents(MODULE_NAME)
With myComponent.CodeModule
For I = 1 To .CountOfLines
strLine = Trim(.Lines(I, 1))
If Left(strLine, Len(RELMARKER)) = RELMARKER Then
.DeleteLines I, 5
.InsertLines I, strNewHistory
Exit For
End If
Next I
End With
'This hopes to change the logo image on the form
Set myComponent = currProj.VBComponents(FORM_NAME)
For I = 1 To myComponent.Designer.Controls.Count
With myComponent.Designer
If .Controls(I).Name = IMAGE_CONTROL_NAME Then
Set myControl = .Controls(I)
'**************************************************************
'This is where it fails because the .Picture is an OLE object.
'**************************************************************
'**************************************************************
'**************************************************************
' Its only properties are
' name Type
' ======= ==============
' Handle OLE_HANDLE
' Height OLE_YSIZE_HIMETRIC
' hPAL OLE_HANDLE
' Type Integer
' Width OLE_XSIZE_HIMETRIC
'**************************************************************
myControl.Picture = "newLogo" ''?????
Exit For
End If
End With
Next I