+ Reply to Thread
Results 1 to 4 of 4

Open WB / Run Macro / Save changes /Close WB

Hybrid View

nachousa Open WB / Run Macro / Save... 06-23-2010, 10:06 AM
EK1 Re: Open WB / Run Macro /... 06-23-2010, 10:55 AM
nachousa Re: Open WB / Run Macro /... 06-23-2010, 12:24 PM
EK1 Re: Open WB / Run Macro /... 06-24-2010, 01:08 PM
  1. #1
    Registered User
    Join Date
    06-10-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    70

    Open WB / Run Macro / Save changes /Close WB

    I already wrote a code to open a file and run the Macro. But im just having trouble saving it and closing it. I tried the function Workbooks.close but this closes all of my open workbooks, I just want to close that specific one.
    Here's what I have so far.

    Sub Transfer_Replace()
    aux = Application.GetOpenFilename("File, *.*")
    ' open workbook if Cancel wasn't pressed
    If aux <> False Then Workbooks.Open aux
    '''Call Macro
    Replace1
    End Sub

  2. #2
    Registered User
    Join Date
    03-01-2010
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Open WB / Run Macro / Save changes /Close WB

    I've used the following method a few times with success.

    
    Dim destWorkbook As Workbook
    
    Set destWorkbook = Workbooks.Open("asdf\asdf\asdf\asdf\sample.xls")
    
    destWorkbook.Save
    destWorkbook.Close

  3. #3
    Registered User
    Join Date
    06-10-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Open WB / Run Macro / Save changes /Close WB

    Thanks. That works fine.

  4. #4
    Registered User
    Join Date
    03-01-2010
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Open WB / Run Macro / Save changes /Close WB

    Mark the thread [SOLVED] if everything you wanted is here.

+ 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