| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

Excel VBA プロパティのコードを生成する

提供: MyMemoWiki
ナビゲーションに移動 検索に移動

Excel VBA プロパティのコードを生成する

Excel VBA | Python |

# -*- coding: utf-8 -*-

def make_vba_properties():
    
    fields = ['aaa','bbb','ccc']
    comments = ['AAA','BBB','CCC']
    
    for i in range(len(fields)):
        print 'Private m_%s\t\t\tAs String\t\' %s' % (fields[i], comments[i])
    
    for i in range(len(fields)):
        
        print '\
        print '\' %s' % (comments[i])
        print '\
        print 'Public Property Get %s() As String' % (fields[i])
        print '\t%s = m_%s' % (fields[i], fields[i])
        print 'End Property'

        print '\
        print '\' %s' % (comments[i])
        print '\
        print 'Public Property Let %s(ByVal %s As String)' % (fields[i], fields[i])
        print '\tm_%s = %s' % (fields[i], fields[i])
        print 'End Property'

if __name__ == '__main__':
    make_vba_properties()