VBA Code Issue (SharePoint)

JDSOuth49

New Member
Joined
Feb 16, 2024
Messages
46
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You might need to post more information. Keep in mind that no one but you knows what you mean by "Does not work properly" or what happens when other people use the workbook. This forum gets a lot of traffic, and mostly it is easier to move on to someone else's post who has done a better job of explaining and providing details of what went wrong, than it is to ask you a lot of questions to get the details. I suspect when people-not-you run it, either the sharepoint path is a problem, or they don't realize how far down the sheet the images are inserted. But there is not enough information for that to be more than a guess.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,155
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top