Macro no longer working with new computer

sclin16

New Member
Joined
May 9, 2017
Messages
10
Hi,

I have the below macro and just got a new work comp. New comp is unable to run my macro now. I think it might be a Windows 10 issue? I'm also running Office 365. Can anyone please help? I essentially need to have a macro look up a number in column E, find the corresponding jpg in a specific folder, and populate that image in column B.

Thanks in advance for your help!
Code:
Sub Kok()
On Error Resume Next
Dim i%, ppath$, sku$


For i = 6 To 500
 sku = Cells(i, 5)
 ppath = "H:\Retail\E-Commerce\Photo Shoots" & sku & "" & sku & "_00_r17.jpg"


With ActiveSheet.Pictures.Insert(ppath)
With .ShapeRange
.LockAspectRatio = msoTrue
.Width = 30
.Height = 40
End With
.Left = ActiveSheet.Cells(i, 2).Left
.Top = ActiveSheet.Cells(i, 2).Top
.Placement = 1
.PrintObject = True
End With
Next
End Sub
 
Last edited by a moderator:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
File path is the same as well as Excel (365). The only difference is Windows, I think. I'm now on Windows 10 vs 7.
 
Upvote 0
What happens when you try to run it?
Are you getting any error messages (if so, what is that message, and if it gives you a "Ddebug" option, what line of code does it highlight)?
What happens if you try to Compile the code before running it?
 
Upvote 0
Office 365 isn't a version. It's a bundle of software you can buy into. Excel itself would be like Excel 2010, Excel 2013, Excel 2016. If you do a search in the windows icon for excel it should pop up with excel and the version number. For instance mine will be Excel 2013. My guess is you don't know what version of excel you were running. If the file path hasn't changed, you've probably got an updated version of excel where a function is no longer used.
 
Last edited:
Upvote 0
If the file path hasn't changed, you've probably got an updated version of excel where a function is no longer used.
That doesn't happen all that often. New things are often added, but old items are seldom deprecated. There were a few things back with Excel 2007, I think, but I have not seen much taken away since then.
What I more commonly see with these type of problems is that the VBA uses some special libraries that they haven't selected yet on their new computer.

If they still have access to a computer where it runs, it is really easy to find this out. Simply go to a computer where it works, go to the VB Editor, go to the Tools menu, click on References, and note all the libraries which are selected.
Then, repeat the same steps on the computer where it is not working, and note if there are any missing references. Often times, there will be references available, but with a higher version number. Clicking on the most current similar reference usually fixes the problem.

Usually, if you have these kind of issue (or a function that was deprecated), compiling the code first (like I suggested in the previous post) will point you to the offending line.
Identifying the problematic code is half the battle!
 
Last edited:
Upvote 0
That doesn't happen all that often. New things are often added, but old items are seldom deprecated. There were a few things back with Excel 2007, I think, but I have not seen much taken away since then.
What I more commonly see with these type of problems is that the VBA uses some special libraries that they haven't selected yet on their new computer.

If they still have access to a computer where it runs, it is really easy to find this out. Simply go to a computer where it works, go to the VB Editor, go to the Tools menu, click on References, and note all the libraries which are selected.
Then, repeat the same steps on the computer where it is not working, and note if there are any missing references. Often times, there will be references available, but with a higher version number. Clicking on the most current similar reference usually fixes the problem.

Usually, if you have these kind of issue (or a function that was deprecated), compiling the code first (like I suggested in the previous post) will point you to the offending line.
Identifying the problematic code is half the battle!

Thanks for the suggestions and being patient with me! So I checked the References and the same libraries are selected on both computers. I also compiled the code (I think?) via Debug -> Compile VBAProject and nothing happened. I have Excel 2016 installed on both computers.
 
Upvote 0
So what happens exactly when you try to run it?
Does it return errors (if so, what are the errors, and what line of code does it highlight if you hit debug)?
Or does it run, but just not appear to do anything?
 
Upvote 0
What happens if you remove the line in red & than run the code
Code:
Sub Kok()
[COLOR=#ff0000]On Error Resume Next[/COLOR]
Dim i%, ppath$, sku$


For i = 6 To 500
 sku = Cells(i, 5)
 ppath = "H:\Retail\E-Commerce\Photo Shoots" & sku & "" & sku & "_00_r17.jpg"


With ActiveSheet.Pictures.Insert(ppath)
With .ShapeRange
.LockAspectRatio = msoTrue
.Width = 30
.Height = 40
End With
.Left = ActiveSheet.Cells(i, 2).Left
.Top = ActiveSheet.Cells(i, 2).Top
.Placement = 1
.PrintObject = True
End With
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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