+ Reply to Thread
Results 1 to 3 of 3

VBA script to close Excel file opened in Outlook

  1. #1
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    241

    VBA script to close Excel file opened in Outlook

    Using VB I need to close a workbook that I opened with Outlook. I open the excel file manually by double-clicking on an attachment in outlook and then run a vba script file that copies some of the contents to another excel file that is opened within the script. (The script is executed from my personal workbook.) I may have multiple workbooks open including my personal workbook and the newly created workbook but I only want to close the one manually opened from Excel. Any ideas?

    Note: The file opened in outlook has variable filenames.

    Thanks,

    Met

  2. #2
    Valued Forum Contributor Hawkeye16's Avatar
    Join Date
    02-27-2013
    Location
    Holland
    MS-Off Ver
    ├•┤ Pew Pew
    Posts
    441

    Re: VBA script to close Excel file opened in Outlook

    How do you reference the workbook opened from Outlook when copying data from it in your macro?

    If you use a name Workbooks("Name").Close
    If you use reference Workbooks(1).Close
    If you use a variable wkbk.Close
    Despite the high cost of living, it remains very popular.

    Don't forget to mark threads SOLVED when you get an answer and rep all the geniouses that helped you today!

  3. #3
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    241

    Re: VBA script to close Excel file opened in Outlook

    Being able to reference the workbook is my problem. (I will open the inital file through Outlook and it has random filenames.)

    My best option at this point is to make sure I have no other Excel files open and close the file via the Workbooks(2).Close option. (My personal workbook resides in slot 1.) I thought about having some sort of selection but I have decided against this as I could just as easily close the window manually. I think I have just overthought this task. In any case, Hawkeye, thank you for your response.


    Thanks,
    Met

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Close current tab of excel file in IE with script?
    By WL2005HBD in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2014, 09:34 PM
  2. Automatic close Help file (.chm) which was opened with Excel user form
    By leecs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2013, 06:02 AM
  3. Sending the Excel file to multiple recipient in outlook application using macro script
    By vigneshwaran in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-19-2012, 03:55 AM
  4. Script to fetch PDF file from Outlook and process it to Excel.
    By neaz1st in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2012, 01:31 PM
  5. [SOLVED] Excel Exits on File Close with Outlook
    By Erin Searfoss in forum Excel General
    Replies: 1
    Last Post: 01-16-2005, 06:06 PM

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