VBA error - Variable not defined (PLEASE HELP!!)

Wh1t3Man2nd

New Member
Joined
Feb 22, 2014
Messages
2
Hi there,
Im new here and I'd like you to help me in a problem i have as i searched all over the internet and found nothing.
I have this VBA code for excel for fixing broken text in excel 2007. It works in Word 2007 but not in excel.

Code:
Option Explicit 
Sub FixBrokenText()
Dim arr1 As Variant, arr2 As Variant, i As Integer
arr1 = Array(180, 161, 162)
arr2 = Array(900, 901, 902)
With ActiveDocument.Range.Find
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
For i = 184 To 254
.Text = ChrW(i)
.Replacement.Text = ChrW(i + 720)
.Execute Replace:=wdReplaceAll
Next
For i = 0 To UBound(arr1)
.Text = ChrW(arr1(i))
.Replacement.Text = ChrW(arr2(i))
.Execute Replace:=wdReplaceAll
Next
End With
End Sub

and when i try to execute it i get this dialog box.. can someone help me solve this problem??
P.S. sry for my english! :)
Thank you very much!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
That doesn't work in Excel because it uses methods from Word. Excel knows nothing about an "ActiveDocument"
 
Upvote 0
Oh,
can we make it work in excel by adding or removing stuff?? im not that good in programming so forgive me for my unawareness of the subject.. :)
 
Upvote 0
Sure. Could you explain what you're trying to do?
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,975
Members
449,200
Latest member
Jamil ahmed

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