Results 1 to 3 of 3

Thread: [RESOLVED] Close.xls file by a macro

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2020
    Posts
    24

    Resolved [RESOLVED] Close.xls file by a macro

    Hi Experts,

    I have a problem & looking for a macro that will do the below things

    I downloaded an .xls file, as soon as file is downloaded it opens up automatically & I have file name macro1.xlsm & I need a macro that will close that .xls file by a macro (I will put the macro in macro1.xlsm & whenever I download that file & it will open automatically then I will open macro1.xlsm & I will run the macro & that file will be closed

    Thnx for the Help

    I am looking for a VBA macro & Yes I can do it manually but I will not do it manually(I have reasons for that)

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Close.xls file by a macro

    if the macro will be in the workbook you want to close
    Code:
    thisworkbook.close, false  '  true if you want to save it
    if that is the only workbook open and you want to close excel as well, add
    Code:
    application.quit

    if the macro is in someother workbook then
    Code:
    workbooks("macro1.xlsm").close false
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2020
    Posts
    24

    Re: Close.xls file by a macro

    Thnx Alot Westconn1 Sir for helping me in solving this problem
    Problem Solved
    Have a Awesome Day

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width