Results 1 to 4 of 4

Thread: [RESOLVED] Dynamic Control-names in dotm or docm macros

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    7

    Resolved [RESOLVED] Dynamic Control-names in dotm or docm macros

    I have a question about dynamic Control-names in a Dotm or Docm (template w macro or document w macro)
    as there will be alot of code, if hardcoding the controlnames.
    I am not so used to word programming more java etc but hopefully one can do the same in word VBA and use "alias" variables for controls right?

    As I have a relation: Combobox1 should change Label1.caption when changed, Combobox2 should change Label2.caption when changed
    This seemed to be a good idea. But no luck here , nothing seems to work

    my erroneous tries:

    Code:
    Public Sub ComboBox1_Change()
    DoLabel ("1")
    End Sub
    
    
    
    
    Public Sub DoLabel(ByVal nr As String)
    MsgBox (nr)
    Dim ctr As Control, nameStr As String
    
    'ctr= "Label" & nr
    
    ctr.Name = "Label" & nr
    
    Me.ctr.Caption = "Show this text"
    
    'Also tried 
    
    Me.ctr."Label" & nr.Caption="show this text"
    
    namestr="Label"&nr 
    'me.namestr.Caption="show this text"
    
    End Sub
    Last edited by Bockstensmannen; Apr 26th, 2013 at 08:01 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width