Good morning.
I have 2 questions about my code:
1. The Print Sub - Does not work properly. (I may have it place improperly)
2. The "Add Picture" Sub works great on my computer, but not for anyone else. (Especially when I put the file into share point and other people try to use the file)
Is there a different SUB that needs to be used?
Thank you in advance.....
Public Sub Print_Specific_Pages()
With ActiveSheet
If .Range("D122").Value > 0 Then
.PrintOut From:=1, To:=4
ElseIf .Range("D166").Value > 0 Then
.PrintOut From:=1, To:=5
ElseIf .Range("D210").Value > 0 Then
.PrintOut From:=1, To:=6
Else
.PrintOut From:=1, To:=3
End If
End With
End Sub
Sub ADD_PICTURE_1()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A82").Left
.Top = ActiveSheet.Range("J82").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A82:J99").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_2()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K82").Left
.Top = ActiveSheet.Range("T82").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K82:T99").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_3()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A102").Left
.Top = ActiveSheet.Range("J102").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A102:J119").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_4()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K102").Left
.Top = ActiveSheet.Range("T102").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K102:T119").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_5()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A123").Left
.Top = ActiveSheet.Range("J123").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A123:J140").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_6()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K123").Left
.Top = ActiveSheet.Range("T123").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K123:T140").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_7()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A143").Left
.Top = ActiveSheet.Range("J143").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A143:J160").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_8()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K143").Left
.Top = ActiveSheet.Range("T143").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K143:T160").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_9()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A167").Left
.Top = ActiveSheet.Range("J167").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A167:J184").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_10()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K167").Left
.Top = ActiveSheet.Range("T167").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K167:T184").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_11()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A187").Left
.Top = ActiveSheet.Range("J187").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A187:J204").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_12()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K187").Left
.Top = ActiveSheet.Range("T187").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K187:T204").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_13()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("211").Left
.Top = ActiveSheet.Range("211").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A211:J228").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_14()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K211").Left
.Top = ActiveSheet.Range("T211").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K211:T228").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_15()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A231").Left
.Top = ActiveSheet.Range("J231").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A231:J248").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_16()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K231").Left
.Top = ActiveSheet.Range("T231").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K231:T248").Height
.PrintObject = True
End With
End Sub
I have 2 questions about my code:
1. The Print Sub - Does not work properly. (I may have it place improperly)
2. The "Add Picture" Sub works great on my computer, but not for anyone else. (Especially when I put the file into share point and other people try to use the file)
Is there a different SUB that needs to be used?
Thank you in advance.....
Public Sub Print_Specific_Pages()
With ActiveSheet
If .Range("D122").Value > 0 Then
.PrintOut From:=1, To:=4
ElseIf .Range("D166").Value > 0 Then
.PrintOut From:=1, To:=5
ElseIf .Range("D210").Value > 0 Then
.PrintOut From:=1, To:=6
Else
.PrintOut From:=1, To:=3
End If
End With
End Sub
Sub ADD_PICTURE_1()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A82").Left
.Top = ActiveSheet.Range("J82").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A82:J99").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_2()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K82").Left
.Top = ActiveSheet.Range("T82").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K82:T99").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_3()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A102").Left
.Top = ActiveSheet.Range("J102").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A102:J119").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_4()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K102").Left
.Top = ActiveSheet.Range("T102").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K102:T119").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_5()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A123").Left
.Top = ActiveSheet.Range("J123").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A123:J140").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_6()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K123").Left
.Top = ActiveSheet.Range("T123").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K123:T140").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_7()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A143").Left
.Top = ActiveSheet.Range("J143").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A143:J160").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_8()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K143").Left
.Top = ActiveSheet.Range("T143").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K143:T160").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_9()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A167").Left
.Top = ActiveSheet.Range("J167").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A167:J184").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_10()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K167").Left
.Top = ActiveSheet.Range("T167").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K167:T184").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_11()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A187").Left
.Top = ActiveSheet.Range("J187").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A187:J204").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_12()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K187").Left
.Top = ActiveSheet.Range("T187").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K187:T204").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_13()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("211").Left
.Top = ActiveSheet.Range("211").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A211:J228").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_14()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K211").Left
.Top = ActiveSheet.Range("T211").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K211:T228").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_15()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("A231").Left
.Top = ActiveSheet.Range("J231").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("A:J").Width
.Height = ActiveSheet.Range("A231:J248").Height
.PrintObject = True
End With
End Sub
Sub ADD_PICTURE_16()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Picture to fit in the range....
.Left = ActiveSheet.Range("K231").Left
.Top = ActiveSheet.Range("T231").Top
.ShapeRange.LockAspectRatio = msoFalse
.Placement = xlMoveAndSize
.Width = ActiveSheet.Range("K:T").Width
.Height = ActiveSheet.Range("K231:T248").Height
.PrintObject = True
End With
End Sub