+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20

Thread: Open workbook and apply code

  1. #16
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    423

    Re: Open workbook and apply code

    Hi JapanDave,

    Thank you for troubleshooting and what a great idea.

    I wonder, however, if this solution will pose another potential problem:

    The only reason I'm having my original workbook call THIS one to open is to get data from THIS workbook for the purpose of reporting data that has been collected in BOTH workbooks.

    When we don't do reports yet but are just collecting data, when user tries to open THIS workbook, it then try to have the original workbook open according to your code and this won't be desirable. (we have users users collect data in two different workbooks but report in together).

    So, in a sense, what I'm trying to do then is......if the sub workbook is being called by another workbook, then use your code to have it open. If the sub workbook is opened directly without being called open by the main workbook, go through the original password code line...

    I wonder if I should just go with the original code you previously helped me with(just be content with the way it was)

    Any other ideas?

    Thank you

  2. #17
    Valued Forum Contributor JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    Japan
    MS-Off Ver
    Excel 2010
    Posts
    779

    Re: Open workbook and apply code

    It is hard to know how a set of workbooks will be used, but if you are always using them at the same time then another solution is in order. I always go to the easiest way to over come a problem first. I will have another look at the code.
    If you are happy with the answer, please click the Star icon in the below left hand corner.

    Good sites to start learning.

    snb's VBA Help Files
    Jerry Beaucaires Excel Assistant
    J & R Excel Consultancy Services

    How to post code correctly: Correct Code Posting

  3. #18
    Valued Forum Contributor JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    Japan
    MS-Off Ver
    Excel 2010
    Posts
    779

    Re: Open workbook and apply code

    This code is working for me.

    Private Sub CalculateTotalClinicVolume_Click()
    
    
        
        Application.EnableEvents = False  'This disables all events for all books, so no macro should run while this is false
    
        Set wbPath = Workbooks.Open("C:\Users\Owner\Desktop\JapanDaveSub.xlsm", Password:="test")
          'your code here
            
            'closing SPH workbook
       wbPath.Close savechanges:=False
       
       Application.EnableEvents = True
            
           
    
    End Sub
    If you are happy with the answer, please click the Star icon in the below left hand corner.

    Good sites to start learning.

    snb's VBA Help Files
    Jerry Beaucaires Excel Assistant
    J & R Excel Consultancy Services

    How to post code correctly: Correct Code Posting

  4. #19
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    423

    Re: Open workbook and apply code

    Quote Originally Posted by JapanDave View Post
    This code is working for me.

    Private Sub CalculateTotalClinicVolume_Click()
    
    Application.EnableEvents = False  'This disables all events for all books, so no macro should run while this is false
    
    End Sub
    Wow nice JapanDave, and it works!!!

    Thank you very much for hanging in there with me.

  5. #20
    Valued Forum Contributor JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    Japan
    MS-Off Ver
    Excel 2010
    Posts
    779

    Re: Open workbook and apply code

    Great you have sorted it out.
    But, I should say I already made this suggestion in post #11.
    If you are happy with the answer, please click the Star icon in the below left hand corner.

    Good sites to start learning.

    snb's VBA Help Files
    Jerry Beaucaires Excel Assistant
    J & R Excel Consultancy Services

    How to post code correctly: Correct Code Posting

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0