+ Reply to Thread
Results 1 to 5 of 5

Running a macro in a generated/unsaved WorkBook

  1. #1
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    304

    Running a macro in a generated/unsaved WorkBook

    Hi. Just a question, not a real problem.
    How do I go about running a macro in an unsaved workbook that is generated by a software program? The workbooks as they are generated will have a name like "Book1", "Book2","Book3", etc. This is the name they get as they are generated and they are unsaved.
    I have tried and it's impossible to refer to the workbook from a macro since generating the workbooks starts another EXCEL process.
    Is there a way to create a macro that can run in ANY open workbook? It will just do a simple thing, save the workbook with the name :
    Please Login or Register  to view this content.
    Thanks for any advice.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Running a macro in a generated/unsaved WorkBook

    Not sure what program you are using to create the workbook.

    With VB Script, you can run a macro from a closed workbook.
    Possibly the software you are using can run a macro from a closed workbook.

    This code will run without opening the workbook, it runs the macro Button1_Click and it is located in Module1

    It is a text file and would be saved as .vbs
    Please Login or Register  to view this content.
    2-11-2016 3-44-36 AM.jpg

    Please note:
    I do not use VB Scripts, I just know they exist, and that this sample is the only one I have ever tested

  3. #3
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    304

    Re: Running a macro in a generated/unsaved WorkBook

    Thanks for your answer Dave. I haven't worked with VB scripts either, but to be honest I don't see this working. As I mentioned, the workbooks are unsaved(they have never been saved), so they are just "open" and they don't have a path to refer to. There will be around 60 workbooks open that need to be saved with the name in each workbook sheet1 "C1" value. Saving each workbook manually so it has a path is what I am doing now, which is quite tedious.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Running a macro in a generated/unsaved WorkBook

    You haven't indicated what program you are using to create the workbooks.

  5. #5
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    304

    Re: Running a macro in a generated/unsaved WorkBook

    No, I haven't because I didn't think it was of any consequence. It's not a popular software, it's basically an Access database that has a user interface to filter the data, and an option to export the filtered data to Excel.
    In any case, I think my problem is very hard to solve in Excel, so I will look into an option to automatize this via other kind of macro recorder, not related to Excel. I will record the actions needed to save the file and go on from there. Thank you for your time.

+ 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] access another UNSAVED Excel instance and UNSAVED Notepad text
    By Fire_d in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 12-05-2014, 02:00 AM
  2. [SOLVED] VBA needed to copy data from an open unsaved attachment to existing workbook
    By rob73 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-01-2014, 03:48 PM
  3. [SOLVED] Copy from one unsaved workbook to a new workbook
    By Verbamore in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2014, 02:43 PM
  4. [SOLVED] Activate unsaved workbook from another workbook
    By klallen810 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-17-2013, 12:31 PM
  5. [SOLVED] Using a macro to copy data from an unsaved, nonactive, varying title workbook
    By tableq in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-24-2012, 06:52 PM
  6. test for new, unsaved workbook
    By Doug Glancy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-22-2005, 12:55 AM
  7. How to recover unsaved workbook?
    By P8ja in forum Excel General
    Replies: 1
    Last Post: 11-28-2005, 08:50 AM

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