1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Convert Word XP Macros to Word 2010

Discussion in 'Business Applications' started by Mike_C_55555, Aug 21, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. Mike_C_55555

    Mike_C_55555 Thread Starter

    Joined:
    Aug 21, 2013
    Messages:
    2
    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.
     
  2. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    Can you provide some examples of the code that is failing and include some of the error messages you receive? The issue could be as simple as differences in the object libraries that are being used. Without seeing the code it would be hard to tell.


    Rollin
     
  3. Mike_C_55555

    Mike_C_55555 Thread Starter

    Joined:
    Aug 21, 2013
    Messages:
    2
    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. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,553
    First Name:
    Hans
    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
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1106534

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice