need a little help with LoadPicture

tango71

New Member
Joined
Aug 27, 2019
Messages
12
ok, so here goes. what im trying to achieve is to be able to grab the exact replica or photo of everything included in " Front of check" worksheet and view it on a separate form in vba after clicking a button. sort of like a photo preview. however, when i debug it it crashes at
Code:
Set Picture = LoadPicture("C:\CheckMaster\temp\MyPic.jpg")
what the heck am i missing? Ive been at this for about 3 hours and have tried other things too.

here is what i have so far...
Code:
Private Sub CommandButton1_Click()Sheets(" Front of check").Activate
'Prepare to copy
Range("A1:L20").Copy
Sheets("sheet3").Activate
Range("A1").Select
ActiveSheet.Pictures.Paste Link:=True
ActiveSheet.Pictures.Select
Application.CutCopyMode = False
Dim myChart As String, myPicture As String
Dim picWidth As Long, picHeight As Long


Application.ScreenUpdating = False


myPicture = Selection.Name
With Selection
picHeight = .ShapeRange.Height
picWidth = .ShapeRange.Width
End With


Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet3"
Selection.Border.LineStyle = 0
myChart = Selection.Name & " " & Split(ActiveChart.Name, " ")(2)




 
With ActiveSheet
With .Shapes(myChart)
.Width = picWidth
.Height = picHeight
End With


.Shapes(myPicture).Copy


With ActiveChart
.ChartArea.Select
.Paste
End With


.ChartObjects(1).Chart.Export Filename:="C:\CheckMaster\temp\MyPic.jpg", FilterName:="jpg"
.Shapes(myChart).Cut
End With

Application.ScreenUpdating = True

Set Picture = LoadPicture("C:\CheckMaster\temp\MyPic.jpg")
ActiveSheet.Pictures.Delete


End Sub
 
when i downloaded your example, i ran it and it came up with errors. so im thinking my 365 got corrupted somehow. im going to to do a fresh install and see if that does the trick. out of everything that has been tried at least 1 of them should have worked. ill post the results after clean install.
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I'm running in Excel 2007, maybe someone can help us with the code for 365.
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,762
Members
449,048
Latest member
excelknuckles

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