Perhaps the following will be more helpful. Thanks again.
Private Sub cmdInsert_Click()
Dim AdIsScreened As Boolean
Dim FileName As String
Dim ShapeName As String
Dim ShapeDescription As String
Dim LogoWidth As Single
Dim LogoLeftPos As Single
Dim LogoHeight As Single
Dim LogoPath As String
Dim PW As Single
Dim LM As Single
Dim i As Integer
Dim MoveUp As Boolean
Dim c As Integer
Dim char As String
Dim MoveDown As Boolean
Dim LogName As String
Dim LgHeight As Single
Dim OrgHeight As Single
Dim NwPrcnt As Single
Dim LogoAlign As Single
Dim AlignChoice As String
Dim TextExist As Boolean
Dim EndPara As Boolean
Dim Curserloc As Integer
Dim FirstLine As Boolean
Dim StartofLine As Boolean
On Error GoTo Error_Hand:
Misc.Defaults
Misc.ReadInputFile
Me.Hide
FirstLine = Checks.AtStartOfDoc
If Me.cbAttentionGetter.Value = True Then
Selection.HomeKey wdStory
End If
If Checks.AtStartOfDoc = True And check.AtEndOfDoc = True Then
TextExist = False
EndPara = True
Else
TextExist = True
Selection.EndKey wdLine
If Asc(Selection.Text) = 13 Then
EndPara = True
Else
EndPara = False
Selection.HomeKey wdLine
End If
GoTo PageSetup
End If
PageSetup:
PW = ActiveDocument.PageSetup.PageWidth
LM = ActiveDocument.PageSetup.LeftMargin
Me.Hide
Application.ScreenUpdating = False
'**********MEASUREMENTS FOR LOGO SIZES)
If LgDefSize <> 0 Then
LgHeight = LgDefSize * Style.Agate
Else
Select Case True
Case Me.opSmll
'LogoWidth = (PW - LM) / 2: LogoLeftPos = LM + (LogoWidth / 2)
LogoWidth = SmallLogo
Case Me.opMed
'LogoWidth = (PW - LM) * 0.8: LogoLeftPos = LM + (PW - LM -
LogoWidth) / 2
LogoWidth = MedLogo
Case Me.opLrg
'LogoWidth = PW - LM: LogoLeftPos = LM
LogoWidth = LargeLogo
Case Else
End Select
End If
Select Case True
Case Me.opCenter.Value
LogoAlign = (ActiveDocument.PageSetup.PageWidth - LogoWidth) / 2
AlignChoice = "Center"
Case Me.opLeft.Value
LogoAlign = Selection.ParagraphFormat.LeftIndent
AlignChoice = "Left"
Case Me.opRight.Value
LogoAlign = ActiveDocument.PageSetup.PageWidth - LogoWidth
AlignChoice = "Right"
End Select
If right(LogoPath, 1) <> "\" Then LogoPath = LogoPath & "\"
LogName = Me.txtLogoPath
If Dir(LogName) = "" Then
MsgBox "Logo " & LogName & " does not exist"
Me.Show
Exit Sub
End If
If cbAttentionGetter.Value = True Then
ShapeName = "SYMB-" & Fix(CDbl(Time) * 100000) + CDbl(Date) * 10 &
LogoName
Else
ShapeName = "LOGO-" & Fix(CDbl(Time) * 100000) + CDbl(Date) * 10 &
LogoName
End If
ActiveDocument.Variables.Add ShapeName, ShapeName
DoEvents
If Me.opLrg.Value = True Then
ActiveDocument.Variables.Add ShapeName & "-S", "Large"
ElseIf Me.opMed.Value = True Then
ActiveDocument.Variables.Add ShapeName & "-S", "Medium"
ElseIf Me.opSmll.Value = True Then
ActiveDocument.Variables.Add ShapeName & "-S", "Small"
Else
ActiveDocument.Variables.Add ShapeName & "-S", "Default"
End If
Me.Hide
DoEvents
If Me.cbAttentionGetter.Value = False Then
If TextExist = True Then
If check.AtEndOfDoc = True Then
If Checks.AtStartOfDoc = False Then
MoveUp = True
Selection.TypeParagraph
End If
ElseIf EndPara = False Then
Selection.HomeKey wdLine
StartofLine = True
ElseIf EndPara = True Then
Selection.MoveRight wdCharacter
End If
Else
Selection.TypeParagraph
Selection.HomeKey wdStory
Selection.ParagraphFormat.LineSpacing = 1
End If
End If
'If MoveUp = True Then
' Selection.MoveUp wdLine
' Selection.ParagraphFormat.LineSpacing = 1
'End If
Curserloc = CInt(Selection.Information(wdVerticalPositionRelativeToPage)
+ 2)
Selection.InlineShapes.AddPicture FileName:=LogName, LinkToFile:=False,
SaveWithDocument:=True
ActiveDocument.InlineShapes(1).Select
' if customer wants logos to be set line count
' this function figures out the percentage of change needed
' However, the logo's are width driven, if the depth causes the
' width to be to large, we force the width to the column width
If LgDefSize <> 0 Then
OrgHeight = Selection.InlineShapes(1).Height
NwPrcnt = LgHeight / OrgHeight
Selection.InlineShapes(1).LockAspectRatio = msoTrue
LogoWidth = Selection.InlineShapes(1).width * NwPrcnt
If LogoWidth > ActiveDocument.PageSetup.PageWidth Then
LogoWidth = ActiveDocument.PageSetup.PageWidth - 4
End If
End If
'insert variables
ActiveDocument.Variables.Add ShapeName & "-W", CStr(LogoWidth)
ActiveDocument.Variables.Add ShapeName & "-L", CStr(LogoAlign)
ActiveDocument.Variables.Add ShapeName & "-A", AlignChoice
ActiveDocument.Variables.Add ShapeName & "-N", LogName
ActiveDocument.Variables.Add ShapeName & LogName
ActiveDocument.InlineShapes(1).ConvertToShape.Name = ShapeName
If Me.cbAttentionGetter.Value = True Then
With ActiveDocument.Shapes(ShapeName)
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
.Top = 1
.LockAnchor = True
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
.WrapFormat.Type = wdWrapTight
.WrapFormat.Side = wdWrapRight
.WrapFormat.DistanceLeft = 2
.WrapFormat.DistanceRight = 2
.WrapFormat.DistanceBottom = 0
.WrapFormat.DistanceTop = 0
End With
Else
With ActiveDocument.Shapes(ShapeName)
.width = LogoWidth
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
.Top = 2
.LockAnchor = True
.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
.WrapFormat.Type = wdWrapTopBottom
.WrapFormat.Side = wdWrapBoth
.WrapFormat.DistanceBottom = 1
.WrapFormat.DistanceTop = 1
End With
End If
DoEvents
ActiveDocument.Shapes(ShapeName).Select
Selection.ShapeRange.left = LogoAlign
LogoHeight = CStr(CSng(ActiveDocument.Shapes(ShapeName).Height))
ActiveDocument.Variables.Add ShapeName & "-H", LogoHeight
For i = 1 To ActiveDocument.Shapes.count
If ActiveDocument.Shapes(i).Name = "Screen" Then
AdIsScreened = True
Exit For
End If
Next
If AdIsScreened = True Then
Application.ScreenUpdating = True
Application.ScreenRefresh
For i = 1 To ActiveDocument.Shapes.count
If left(ActiveDocument.Shapes(i).Name, 4) = "LOGO" Then
ActiveDocument.Shapes(i).Select
ActiveDocument.Shapes(i).PictureFormat.Brightness = 0.41
End If
Next
End If
Application.ScreenRefresh
Application.ScreenUpdating = True
Selection.EndKey wdStory
If StartofLine = False Then Selection.EndKey wdLine
Unload Me
Exit Sub
Error_Hand:
Dim res As Integer
res = ErrorHandler.ErrorHandler("In procedure cmdInsert_Click of Form
frmInsertLogos", Err, DataError & ":" & ErrorMessage)
End Sub