Where did you place the Private Sub Workbook_Open macro? (It belongs in the Thisworkbook module)
also, instead of having the user enter the version number, why not have the macro READ the number? (that is, unless the name of the original file (File A) changes) also: what I have done is create a Save event in the original workbook that writes the version number to a file (OK, I write it to an Oracle database, but still, the concept is the same). Then, when the user opens the Original file, it checks the version against the stored "latest" version. That way, if they copy the file and open the copy, it will warn them at that time. Paul ----------------------------------------- “Do all the good you can, By all the means you can, In all the ways you can, In all the places you can, At all the times you can, To all the people you can, As long as ever you can.” - John Wesley ----------------------------------------- >________________________________ > From: james griffin <grapegr...@gmail.com> >To: excel-macros@googlegroups.com >Sent: Thursday, February 27, 2014 5:29 PM >Subject: $$Excel-Macros$$ Run macro when file is opened by another excel file? > > > >Hi. I want to have a file automatically check the version of another file >that opens it to post information to it. Information is entered into File A >and then File A calls File B to transfer information to (i.e. a summary). The >code I have written in File A is: > > SetAttr "File B", vbReadWrite > Workbooks.Open Filename _ > :="File B.xlsm" _ > , UpdateLinks:=0 > > ActiveWorkbook.Unprotect > Sheets("Plan Check Log").Select > ActiveSheet.Unprotect 'unprotect sheet to write plan check results > >This has been working fine but I need to be sure that users are using the >correct version of File A to transfer information. So I thought I would write >a macro in File B that would run automatically when the File is opened: > > Private Sub Workbook_Open() > Dim myValue As Variant >' >' Auto_Open Macro >' Checks to see that correct version of checklist is being used. >' > myValue = InputBox("Enter version number of checklist: Found on >first page 'Start Here', upper right hand corner") > If (myValue = "2") Then > Continue > Else > MsgBox ("You are using the incorrect checklist! You must use >the checklist found on the L:drive in the Plan Check folder to update the >Plan Check log. Sorry for the inconvienence.") > End > End If > >However, the macro is not getting run. Thanks for any suggestions. -- >Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s >=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >https://www.facebook.com/discussexcel > >FORUM RULES > >1) Use concise, accurate thread titles. Poor thread titles, like Please Help, >Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get >quick attention or may not be answered. >2) Don't post a question in the thread of another member. >3) Don't post questions regarding breaking or bypassing any security measure. >4) Acknowledge the responses you receive, good or bad. >5) Jobs posting is not allowed. >6) Sharing copyrighted material and their links is not allowed. > >NOTE : Don't ever post confidential data in a workbook. Forum owners and >members are not responsible for any loss. >--- >You received this message because you are subscribed to the Google Groups "MS >EXCEL AND VBA MACROS" group. >To unsubscribe from this group and stop receiving emails from it, send an >email to excel-macros+unsubscr...@googlegroups.com. >To post to this group, send email to excel-macros@googlegroups.com. >Visit this group at http://groups.google.com/group/excel-macros. >For more options, visit https://groups.google.com/groups/opt_out. > > > -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/groups/opt_out.