Macro word 2013 vs 2010

Hi,

i've made a office word 2010 template with macro.

I am now using Office word 2013.

When i open the document back with Office 2010, macro doesn't work. Word change all my object name, adding 1 to the end.

So for example, textbox became textbox1 and so on. When I enable macro, macro run, but since it can't find my object it ends up in error.

When I open document with word 2013 i don't have any problem at all.

Macro are very simple macro using active x object (for example loading a list into a combo box on document open with .list ecc.)

Could someone help me?

Because I have no clue on how to check out error, since im running just office 2013 and i've to try and send file.

It can be the file is open in read only?

Thank you so much.

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.

The default names that Office uses for shapes are prone to being changed without warning, as you have discovered. The way around this is to name the shapes yourself. The names you assign will not be changed by Word, and it's a chance to give them more meaningful names for your programming code.

Here are 2 utility macros I use to set and get the names of shapes including text boxes:

Sub SetShapeName()
    Dim ShapeName$
    On Error GoTo AbortNameShape
    If ActiveWindow.Selection.ShapeRange.Count = 0 Then
        MsgBox "No Shapes Selected"
        Exit Sub
    End If
    ShapeName$ = ActiveWindow.Selection.ShapeRange(1).Name
    ShapeName$ = InputBox$("Give this shape a name", "Shape Name", ShapeName$)
    If ShapeName$ <> "" Then
        ActiveWindow.Selection.ShapeRange(1).Name = ShapeName$
    End If
    Exit Sub
AbortNameShape:
    MsgBox Err.Description
End Sub

Sub GetShapeName()
    Dim ShapeName$
    ShapeName$ = ActiveWindow.Selection.ShapeRange(1).Name
    MsgBox ShapeName$
End Sub

Author of "OOXML Hacking - Unlocking Microsoft Office's Secrets", ebook now out
John Korchok, Production Manager
production@brandwares.com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

hi, thanks for the answer.

I don't get why from 2013 to 2010 object name change. But i have still a question. I need to give persistant name to object So the user who compile my template can use it.

I don't get how to use that set/get name macro.

Could you explain further.

Thank you so much

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I don't know why Word changes the names either, but I've seen it happen more than once.

Copy the macros to your normal template. You can create keyboard shortcuts or QAT icons for them to access them more easily. I can tell you how to do that if you're unsure.

Then select a textbox. If you run the GetShapeName macro, it will display the current name as assigned by Word. If you run SetShapeName, it will display an Input Box to let you enter a new name for the text box.

Once you have assigned names that make sense, go back to your original macro and change the old text box names to the new ones. This time they won't change.

Author of "OOXML Hacking - Unlocking Microsoft Office's Secrets", ebook now out
John Korchok, Production Manager
production@brandwares.com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I've created a module in my project, paste there the macro.

I place my focus on a textbox and i run Getnames, but i get error when executing the macro.

Should I use this not in design mode right?

I tried it and it works for shapes like square and so on, but doesn't work for textbox or combobox

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

The code that John has given you is for naming a Shape TextBox, and it will not work for ActiveX controls.

To give a meaningful name to an ActiveX control, while in Design mode, click on the control and then on the Properties button in the Controls section of the Developer tab of the ribbon and enter the name in the Properties dialog that appears.

It certainly does make writing code easier if you give the controls meaningful names.

Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Thanks for your answer. I try to explain my problem better.

I assigned all my textbox and combobox names, while in design mode, clicking on my textbox and then in developer tab clicking on properties. Then in name, i give it a name. My name are all set by me that way.

The problem is that when i save my document with word 2013, and i open it with word 2010, I click on enable macros, but on Document open sub it fails. When i go check all my object i see that word, add to all my active x object name a "1".

I don't understand if it's a compatibility issue or im doing something wrong.

I get error "Can't exit design mode because control Mynamexxx cannot be created" When i check my document I see my activex control is now named Mynamexxx1. I see that word start to load activex from end of the document, because the first error I get is from last active X content.

Then macro simply stop loading.

If I go to object browser, under project thisdocument i see that all my object are doubled. I can see Mynamexxx and Mynamexxx1. It's like word create another object since the normal one already exist, it add 1 to the end. (but i can see just Mynamexxx1 object on the document)

Hope this explain my problem

EDIT: I did another try. Paste everything in a new document. Open with word 2010 is fine, save it with 2013 and open again with 2010, same error

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Can you send me a copy of the template so that I can investigate the problem.
Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Can you post the macro code you are running? When I create ActiveX textboxes in 2013, save and open in 2010, the names are unchanged, so something else must be going on.
Author of "OOXML Hacking - Unlocking Microsoft Office's Secrets", ebook now out
John Korchok, Production Manager
production@brandwares.com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I try to do a simple code:

Private Sub Document_Open()
    Me.template.List = Array("Select", "Offer1", "Offer2", "Offer3")
End Sub

I put a combo box in the document and call it template.

I open in 2010 and it works fine,

i open in 2013 and it works fine,

i save in 2013

i re open in 2010.

My combobox show the last saved values, but when i try to select other values is blank.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I'll send you the template tomorrow. But if you look at my last answer, i tried just to do a single combobox, and it doesn't work.

Thank you

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.

 
 

Question Info


Last updated October 5, 2021 Views 596 Applies to: