Tech Support Guy banner
Status
Not open for further replies.

Convert Word XP Macros to Word 2010

2K views 3 replies 3 participants last post by  Keebellah 
#1 ·
Hi All,

My office is upgrading from Office XP to Office 2010. We have a dozen different macros written for Office XP. They are all Word documents. Each produces a different form. Some have only about a dozen fields to populate. Others have up to 100 different options.

These macros run great in Word XP but crash when run in 2010 with a variety of VB errors. All our users are running Windows 2007 with the latest service pack.

Is there an easy method to upgrade these macros to 2010 format, without having to learn enough VB programming to recode all of them? I have an MSDN subscription and one idea was to try a gradual upgrade - from Word XP to Word 2003, then Word 2007, then Word 2010 - just alot of testing VMs to set up...

Thank you,

Mike C.
 
#3 ·
All,

Thanks for your feedback. Running one of our macros in Word 2010 Pro I get the following error:

"Runtime error '4605':

The selected method or property is not available because some or all of the object does not refer to a table"

I click debug - here is the code from the form generating the error - the Selection.SelectRow '''' line - 7th line from the bottom - is the one highlighted by the Visual Basic debugger. I made it bold, below

-Mike C.

Private Sub cmdSel_Click()
Dim chargeArray() As String, a As Integer, b As Integer, c As Integer
If txthold.Value = 1 Then
txtn.Value = txtCts.Value
fixme = txtCts.Value
txthold.Value = 0
End If
If txta.Value > 1 Then
ActiveDocument.Bookmarks("C" & txtb.Value).Select
ffile = cmbChg.Value
ReDim Preserve chargeArray(c)
chargeArray(c) = ffile
txtb.Value = txtb.Value + 1
b = txtb.Value
Selection.TypeText Text:=chargeArray(c)
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:=("C" & b) 'create bookmk for legalese ONE PASS
.DefaultSorting = wdSortByLocation
.ShowHidden = False
End With
c = c + 1
GoTo bye
End If
b = txtb.Value
ffile = cmbChg.Value
ReDim Preserve chargeArray(c)
chargeArray(c) = ffile
ActiveDocument.Bookmarks("C2").Select
Selection.TypeText Text:=chargeArray(c)
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:=("C" & b)
.DefaultSorting = wdSortByLocation
.ShowHidden = False
End With
c = c + 1
a = 2
txta.Value = a
bye:
txtCts.Value = txtCts.Value - 1
txtLeft.Value = txtCts.Value
If txtLeft.Value = 0 Then
ActiveDocument.Bookmarks("c2").Select
Selection.EndKey Unit:=wdStory, Extend:=wdExtend
Selection.ConvertToTable Separator:="*", _
NumColumns:=4, NumRows:=fixme, Format:=wdTableFormatNone, ApplyBorders:=True, _
ApplyShading:=False, ApplyFont:=True, ApplyColor:=False, ApplyHeadingRows _
:=False, ApplyLastRow:=False, ApplyFirstColumn:=True, ApplyLastColumn:= _
True, AutoFit:=True
Selection.GoTo What:=wdGoToBookmark, Name:=("C" & b)
Selection.SelectRow ''''
Selection.Rows.Delete ''''

Unload usrChg
Load usrMainForm
usrMainForm.Show
End If
End Sub
 
#4 ·
I would suggest you attach one of the word documents.
That tells more than 1000 words
The error you mention is probably not XP or 2010 specific, BTW XP is not word version.
It's either Office 95, 2003, 2007 or 2010.
XP is the operating system
 
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top