Trying to get this macro to work in Word VBA. Any help to fix this would be greatly appreciated.
Sub ConvertToMM()
Dim wrdFind As Find
Dim wrdRng As Range
Dim wrdDoc As Document
Dim inch_in As Integer
Dim mm_out As Variant
Set wrdDoc = Application.ActiveDocument
Set wrdRng = wrdDoc.Content
Set wrdFind = wrdRng.Find
inch_in = CVar(mm_out)
mm_out = “”
With wrdFind
Select Case inch_in
Case Is = 0.039
mm_out = “1MM”
Case Is = 0.059
mm_out = “1.5MM”
Case Is = 0.079
mm_out = “2MM”
Case Is = 0.118
mm_out = “3MM”
Case Is = 0.157
mm_out = “4MM”
Case Is = 0.236
mm_out = “6MM”
Case Is = 0.315
mm_out = “8MM”
Case Is = 0.394
mm_out = “10MM”
Case Is = 0.472
mm_out = “12MM”
End Select
End With
wrdRng.Text = mm_out
End Sub
Try using the next function, please:
It can be called/tested with such a code: