excel - Check if pptx and xlsx files are already open before attempt to open it -


i guess easy 1 since i'm new in vba can't figure out.

i have peace of code opens power point presentation , excel spreadsheet. dir_pptx , dir_xlsx respective filepaths.

set objppt = createobject("powerpoint.application") set objpresentation = objppt.presentations.open("" & dir_pptx & "")  workbooks.open filename:=dir_xlsx   

my question: how modify code check if files opened and, if are, don't open again?

sub wbcheck()  each b in application.workbooks      if b.name = dir_xlsx         msgbox b.name & " open"         'exit sub or other handler     else         workbooks.open filename:=dir_xlsx     end if  next  end sub 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -