excel - Reference to a workbook selected with filedialog in vba -


i trying create sort of user interface in excel , need find simple solution copy worksheet selected workbook specific workbook. far i've written code below don't know how reference selected workbook in code. users going need copy worksheet ( it's called storyboard , name never changes ) many different workbooks ( different names ) workbook vba. right workbook can selected, cannot refer workbook in codes.

also, there macros on workbooks users going select, how can disable them after opening?

here code far;

sub storyboard_ekle()     dim dosyasec office.filedialog      set dosyasec = application.filedialog(msofiledialogfilepicker)     dosyasec        .allowmultiselect = false       .title = "lütfen yeni eklenecek storyboard dosyasini seçiniz."       .filters.clear       .filters.add "excel macro-enabled workbook", "*.xlsm"       .filters.add "excel workbook", "*.xlsx"       .filters.add "all files", "*.*"        if .show = true         yenisb = .selecteditems(1)       end if  dim yenistoryboard workbook dim anadosya workbook dim yenistoryboard_sheet worksheet dim anadosya_sheet worksheet  application.screenupdating = false  set anadosya = thisworkbook application.enableevents = false set yenistoryboard = workbooks.open(yenisb)  yenistoryboard.worksheets("storyboard").copy after:=thisworkbook.worksheets("kunye") yenistoryboard.close  set yenistoryboard_isim = sheets("storyboard") yenistoryboard_isim.name = "storyboardxxyyzz" application.enableevents = true     end end sub 

thank much. :)

i think should using solution disable them after opening

application.enableevents = false            'disable events set yenistoryboard = workbooks.open(yenisb) 'open workbook  application.enableevents = true             'enable events 

to ensure disable event of workbook, can use additional statements

yenistoryboard.application.enableevents = false 'do yenistoryboard.application.enableevents = true yenistoryboard.close 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -