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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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,223,275
Messages
6,171,126
Members
452,381
Latest member
Nova88

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