Upgraded from Office 2007 to Professional 2021 and now Macros won't work

Queenofmycastle

Board Regular
Joined
Oct 27, 2009
Messages
62
Office Version
  1. 2016
Platform
  1. Windows
I have a file that I use annually to print lots of forms for 20 "Locations". They pull information to include things such as Location Name, Address, etc..
Our company just upgraded from 2007 20 Professional 2021 and today was the first time I attempted to run any macros.

This is the first one:
Sub PrintEntireSetJ6()
Dim i As Integer


' First choose a printer
Application.Dialogs(xlDialogPrinterSetup).Show

[J6].FormulaR1C1 = "0"
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"


For i = 1 To 20
[J6].FormulaR1C1 = CStr(i)
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Next i
[J6].FormulaR1C1 = "1"
End Sub


This time I am getting a Compile Error "Can't find project or Library" The first line highlights as yellow and the [J6] highlights as blue. Our IT person stated it was probably due to the file name extension being different but I don't know how to fix my problem. Any advice appreciated!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
In your VBE click Tools - References and see if any have the word MISSING next to them
 
Upvote 0
In your VBE click Tools - References and see if any have the word MISSING next to them
1691756032878.png


I appreciate your help! This is what the screen looks like.
 
Upvote 0
Uncheck the Calendar control (assuming you aren't using it in the project; if you are, you have a problem). Then save and re-run.
 
Upvote 0
It Worked! It Worked! I'm doing a happy dance. I have so many forms setup this way and never considered that upgrading Excel would be a problem. I am so grateful for your help. I would have never figured that out.
 
Upvote 0
Glad we could help.

If I remember correctly, the Calendar control was removed from Office from 2010 onwards, so most people have already been through this pain. ;)
 
Upvote 0
You guys were awesome in helping me sort out my problem! I am so very grateful! I have an addendum question I was hoping you could assist me with. I may should have started another thread?

Instead of

For i = 1 To 20

I would like it to be able to do 1,11,21,31.... up to a certain number. Is there any hope?
 
Upvote 0
Try...
VBA Code:
Sub TESTIT()
    Dim i As Long
    For i = 1 To 121 Step 10 ' change 121 to suit
        Debug.Print i
    Next
End Sub
 
Upvote 0
Wonderful! My job doesn't entail Excel use daily but when it does, it is such a blessing! I am beyond grateful!
 
Upvote 0

Forum statistics

Threads
1,215,160
Messages
6,123,355
Members
449,097
Latest member
thnirmitha

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