+ Reply to Thread
Results 1 to 3 of 3

VBA for open files from folder / calling function / save / close the file

  1. #1
    Registered User
    Join Date
    11-18-2019
    Location
    london
    MS-Off Ver
    office 365
    Posts
    1

    VBA for open files from folder / calling function / save / close the file

    Hey there,

    I'd like to get some ideas from ya'all

    I have one code for open files from a folder and calling a macro from other workbook and then save it to the same folder.


    Sub OpenFiles()
    Dim MyFolder As String
    Dim MyFile As String
    MyFolder = "c:\test\"
    MyFile = Dir(MyFolder & "\*.xlsm")

    Do While MyFile <> ""
    Workbooks.Open fileName:=MyFolder & "\" & MyFile

    Application.Run ("'Weekly Sales Report.xlsm'!formulas_auto_refresh_manual")

    MyFile = Dir
    ActiveWorkbook.Close SaveChanges:=True
    Workbook.Close fileName:=MyFolder & "\" & MyFile

    Loop

    End Sub



    The files were able to opened and saved respectively but the macro of 'formulas_auto_refresh_manual' was failed which is as following


    Sub formulas_auto_refresh_manual()

    Dim sh As Workbook

    Application.Calculation = xlAutomatic
    'Do Something
    'Recalc
    Calculate
    ' refresh data
    Application.CalculateFullRebuild
    ActiveWorkbook.RefreshAll
    'Recalc
    Calculate
    'Do More Things
    Application.Calculation = xlManual

    End Sub


    Could anyone help me solve this issue?

    Many many thanks!!

  2. #2
    Forum Contributor
    Join Date
    11-05-2019
    Location
    Tiki Island, TX
    MS-Off Ver
    Office 365
    Posts
    168

    Re: VBA for open files from folder / calling function / save / close the file

    To debug this you will need to provide all of the code and where it fails and what error messages you are getting. The information provided is too generic to debug.

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,496

    Re: VBA for open files from folder / calling function / save / close the file

    And please read the forum rules (tab at the top). In this case, #2 is of interest.

+ 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. [SOLVED] Open files in folder, replace comma with semicolon etc, save and close
    By soreno in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-29-2019, 07:01 AM
  2. "file opener" - code to open another workbook, save as, and close both original files
    By Arnold Layne in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2019, 01:08 PM
  3. [SOLVED] macro to open all files in a folder, save them, then close them
    By hopefulhart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-27-2013, 06:40 PM
  4. Open every file in the folder, remove merge and wrap, save and close files
    By abdesai in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2013, 04:58 PM
  5. [SOLVED] Macro to open and close all files in a folder and sub folders
    By BillDoor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-31-2012, 06:51 AM
  6. Need macro to open, refresh, save, close 50 workbooks in a folder.
    By paulcg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2012, 09:23 AM
  7. I like to open a folder,auto print,save then close
    By tied of opening files in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2005, 06:06 PM

Tags for this Thread

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