+ Reply to Thread
Results 1 to 5 of 5

Run Macro on opening specified document

  1. #1
    Registered User
    Join Date
    07-21-2015
    Location
    West Midlands
    MS-Off Ver
    2010
    Posts
    43

    Run Macro on opening specified document

    Hi there,

    I am trying to create a macro which uses the workbook open event to run only when 1 specific file (which is always in the same folder and has the same name) opens.

    Could someone point me in the right direction at all? or help with just the piece of code that runs on opening by filename?

    Thanks
    Dustin

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Run Macro on opening specified document

    Hi Dustin

    Can you explain a little more what you are trying to do. Let's call the file X.xlsm

    How is file X opened - manually or by macro?
    When X is opened what should happen next?
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Run Macro on opening specified document

    Hi,

    If you put the code into the Workbook_Open event of that file, it will only run when that workbook opens.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Registered User
    Join Date
    07-21-2015
    Location
    West Midlands
    MS-Off Ver
    2010
    Posts
    43

    Re: Run Macro on opening specified document

    Hi kev,

    I use Qlikview to save an extract as CH01.CSV then open the file again via Qlikview (using VB), I then on opening want the vba/macro to run which re-saves the file as CH01.xlsm.

    The workbook_open event isnt triggering when i open my file (i also tried manually opening), but when i step into it and trigger it works.

    The problem is when i run monthly the previous file gets overwritten so i cant put the macro in the file itself.

    Thanks
    Dustin

  5. #5
    Registered User
    Join Date
    07-21-2015
    Location
    West Midlands
    MS-Off Ver
    2010
    Posts
    43

    Re: Run Macro on opening specified document

    Sorry i just realised it was a rookie mistake, I put my private workbook open in a module and it needed to be in the "thisworkbook" tab.

    Thank you for the replies though. I have added the code below just incase it can help anyone else (most of the code i found online, just a few little edits).

    Please Login or Register  to view this content.
    Last edited by aimone111; 05-23-2017 at 06:30 AM.

+ 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. Opening a .CSV as a separate document using VBA on MAC
    By RobHiles in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-23-2016, 04:06 AM
  2. Mail merge data source lost when opening document with Macro
    By jimbojsy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-22-2014, 10:17 AM
  3. NOT update External Links when opening a word document via excel macro
    By debbie2852 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-08-2013, 04:49 PM
  4. Slight problem opening word document from macro
    By DamienC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-11-2009, 10:51 AM
  5. Start Excel Macro upon opening of document
    By Brett in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2005, 02:05 PM
  6. Opening a csv document
    By excel dummie in forum Excel General
    Replies: 0
    Last Post: 03-17-2005, 06:46 PM
  7. Do this when opening new document
    By semtex in forum Excel General
    Replies: 23
    Last Post: 01-08-2005, 10:32 AM

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