excel - Accessing a private field in class module -
i have simplified class module clxxx....
':: backing field private ftemplatebk excel.workbook '::::::::::::::::::::::::::: ':: ':: constructor private sub class_initialize() end sub '::::::::::::::::::::::::::: ':: ':: properties property templatebk() 'as excel.workbook '<< different error messages depending on if "as excel.workbook" included or not templatebk = ftemplatebk end property '::::::::::::::::::::::::::: ':: ':: methods public sub opentemplate() set ftemplatebk = excel.workbooks.open("\\xxx\yyy\zzz.xlsx") end sub public sub somemethod() me.templatebk.sheets(1).activate end sub
normal module:
sub control() dim x clxxx set x = new clxxx x.opentemplate x.somemethod '<<<<<<errors here end sub
i want access private field ftemplatebk
via read-only property templatebk
using code such me.templatebk. ...
. how amend above possible?
you need create property public , must utilize set keyword.
check below code , confirm if works:
private ftemplatebk excel.workbook public property templatebk() excel.workbook set templatebk = ftemplatebk end property
excel vba excel-vba
No comments:
Post a Comment