+ Reply to Thread
Results 1 to 6 of 6

Close inactive Workbook without workbook name

Hybrid View

chrismann85 Close inactive Workbook... 11-16-2009, 10:47 AM
JeanRage Re: Close inactive Workbook... 11-16-2009, 12:24 PM
chrismann85 Re: Close inactive Workbook... 11-17-2009, 02:59 AM
JeanRage Re: Close inactive Workbook... 11-17-2009, 04:06 AM
chrismann85 Re: Close inactive Workbook... 11-30-2009, 09:52 AM
JeanRage Re: Close inactive Workbook... 11-30-2009, 10:08 AM
  1. #1
    Registered User
    Join Date
    01-07-2008
    Location
    Northampton, UK
    MS-Off Ver
    version 2212, office 365 enterprise
    Posts
    74

    Close inactive Workbook without workbook name

    Hi all,

    I have a spreadsheet which will fill columns based on data from a number of other worksheets. For each row, there are three different workbooks to draw data from.

    I have a macro that will prompt the user to browse to a file to open, it will then manipulate and copy the data into the main workbook.

    The only problem I have now is that I want to close the workbook when the macro has finished.

    Here is my code:

    Sub ImportVEESData()
    
       Dim strPath As String
        Dim vntFile As Variant
                    
    'Browse to data file using prompt
        strPath = "R:\Test Operations\Emissions\Processed Data 14-11-08 onwards\SULEV VEES analysis\SULEV Hot Bag 3 Full Gage R and R 4 March 2009 on\"
    
        ChDrive strPath
        
        vntFile = Application.GetOpenFilename("All Files *.*,*.*")
        If vntFile = False Then Exit Sub
        
        Workbooks.Open vntFile
        ActiveSheet.Select
    
    'grab values from this open sheet
        
        Windows("ULEV3 Gauge R&R Summary Sheet - Bag 3.xls").Activate
    
    'paste values into sheet  
        
        
    End Sub

    Any ideas?
    Last edited by chrismann85; 11-16-2009 at 11:26 AM. Reason: removed irrelevant code
    Ne auderis delere orbem rigidum meum!

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Close inactive Workbook without workbook name

    Hi,

    Not sure to understand your question ... may be
    ActiveWorkbook.Close

    HTH

  3. #3
    Registered User
    Join Date
    01-07-2008
    Location
    Northampton, UK
    MS-Off Ver
    version 2212, office 365 enterprise
    Posts
    74

    Re: Close inactive Workbook without workbook name

    Hi JeanRage,

    That is what I would normally use but the workbook I want to close is not the active workbook. And as the user chooses it, the name of the workbook is not written in the macro.

  4. #4
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Close inactive Workbook without workbook name

    Hi,

    In this case, you do have to define in your variables two entities as workbooks ...
    Dim wbk1 As Workbook
    Dim wbk2 As Workbook

    Then, in your code, Assign wbk1 and wbk2 when they are active, ... in order to be able to close the workbook you want ... whenever you want ...
    wbk1.Close

    HTH

  5. #5
    Registered User
    Join Date
    01-07-2008
    Location
    Northampton, UK
    MS-Off Ver
    version 2212, office 365 enterprise
    Posts
    74

    Re: Close inactive Workbook without workbook name

    Hi Jean,

    That did help, thanks

  6. #6
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Close inactive Workbook without workbook name

    Glad you could fix your problem ...

    Cheers

+ 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.6.0 RC 1