ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,280
- Office Version
- 2007
- Platform
- Windows
Code in use is as shown.
The code below does this.
I copy a bar code image from the internet.
I then click on the command button called BAR CODE 1 which is the code shown below & i now see the bar code has been pasted in the cells A8:B10
This works fine apart from when i press the command button i actually see the bar code from say the clipboard appear in cell Y1 then its pasted into the cell A8:B10
I dont see anything in the code that specifies why it appears in Y1 but can we make it appear in a cell off the viewing page say cell AA1
The code below does this.
I copy a bar code image from the internet.
I then click on the command button called BAR CODE 1 which is the code shown below & i now see the bar code has been pasted in the cells A8:B10
This works fine apart from when i press the command button i actually see the bar code from say the clipboard appear in cell Y1 then its pasted into the cell A8:B10
I dont see anything in the code that specifies why it appears in Y1 but can we make it appear in a cell off the viewing page say cell AA1
Rich (BB code):
Private Sub BarCode1_Click()
Dim objPic As Picture
ActiveSheet.Paste
Set objPic = Selection
With ActiveSheet.Range("A8:B10")
If objPic.Width > .Width Then
objPic.Width = .Width
objPic.Left = .Left
Else
objPic.Left = .Left + (.Width - objPic.Width) / 2
End If
If objPic.Height > .Height Then
objPic.Height = .Height
objPic.Top = .Top
Else
objPic.Top = .Top + (.Height - objPic.Height) / 2
End If
End With
End Sub