+ Reply to Thread
Results 1 to 13 of 13

VBA Command to Open Excel Template

  1. #1
    Registered User
    Join Date
    06-19-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    18

    VBA Command to Open Excel Template

    Apologies if this has been answered before, but I am unable to find an existing thread.

    I am trying to write a VBA macro whereby I can press a command button to open another excel workbook template that I have set up separately.

    Any ideas?

    Colin

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA Command to Open Excel Template

    Colin

    Do you want to open the template or do you want to create a new workbook based off the template?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-19-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA Command to Open Excel Template

    Quote Originally Posted by Norie View Post
    Colin

    Do you want to open the template or do you want to create a new workbook based off the template?
    Hi Norie

    The intention is to open an existing template upon pressing the command button.
    I will have a main workbook with 20 or so sheets containing different data.
    On 1 of the sheets, I intend to have a command button that opens a new workbook with a template set up. I would then like some of the data to be transferred into that template in a condensed form in order to share with other users. But for now it is just the macro to open the existing file that I am looking for.

    Regards

    Colin

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA Command to Open Excel Template

    All you need is Workbooks.Open then.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-19-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA Command to Open Excel Template

    Thanks Norie

    I am receiving an error message against the strFilename string;

    Compile Error
    Expected Sub, Function or Property

    What does that mean and is there a way that I can debug it?

    Colin

  6. #6
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: VBA Command to Open Excel Template

    Hi Colin,


    May be a Typo error... "=" sign is missing there.. see below code for refrence..

    Please Login or Register  to view this content.
    Regards
    Parth

    I appreciate your feedback. Hit * if u Like.
    Rules - http://www.excelforum.com/forum-rule...rum-rules.html

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA Command to Open Excel Template

    It's a typo, I've fixed it.

  8. #8
    Registered User
    Join Date
    06-19-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA Command to Open Excel Template

    I am going wrong somewhere, I just can't see it.
    I have put the following code into VBA (I have more or less copied verbatim)
    Please Login or Register  to view this content.
    and I am now receiving the following error message:

    "Runtime error 1004
    Sorry we could not find
    C:\Users\Colin\Desktop\DeliveryNotesDevelopment\DeliveryNote.xlsx
    Is it possible it was moved, removed or deleted?"

    I am certain that I have entered the path and file name correctly.

  9. #9
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: VBA Command to Open Excel Template

    Hi Colin,

    Just checked with the code you posted, yes the file name you wanted to open does not exist in the Folder you specified...

  10. #10
    Registered User
    Join Date
    06-19-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA Command to Open Excel Template

    Quote Originally Posted by Parth007 View Post
    Hi Colin,

    Just checked with the code you posted, yes the file name you wanted to open does not exist in the Folder you specified...
    I am getting closer, I have got the code provided to open an new workbook which I have named "Book1" - just a blank worksheet and it works! But for some reason, my target worksheet template "DeliveryNote" doesn't open despite the path and filename definitely being correct!
    Could there be a setting or a bug in the target worksheet that is preventing the macro from working?
    Last edited by JuneTwentyFourteen; 02-25-2015 at 09:58 AM.

  11. #11
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: VBA Command to Open Excel Template

    Hi Colin,

    If you trying to open a Template then the extension of the file would be either
    (FILENAME.xltm or FILENAME.xlt)

    DeliveryNote.xlsx dont seem to be a Excel Template file.. Please verify

  12. #12
    Registered User
    Join Date
    06-19-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA Command to Open Excel Template

    Quote Originally Posted by Parth007 View Post
    Hi Colin,

    If you trying to open a Template then the extension of the file would be either
    (FILENAME.xltm or FILENAME.xlt)

    DeliveryNote.xlsx dont seem to be a Excel Template file.. Please verify
    Parth, its actually saved as xlsm have changed the filename to that and....... it WORKS!!

    Thanks very much for your time and patience, most appreciated!

  13. #13
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: VBA Command to Open Excel Template

    Hi Colin, PLeas mark the trhead as solved

+ 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. Replies: 56
    Last Post: 09-08-2014, 06:54 AM
  2. Open Excel Template from Access Command
    By acmagyar in forum Access Tables & Databases
    Replies: 3
    Last Post: 04-10-2014, 12:22 PM
  3. Open Command Prompt Through Excel
    By Jiptastic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2014, 07:27 PM
  4. Open Excel Template in New Session
    By Sofistikat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-13-2011, 10:56 PM
  5. Excel Template fails to open???
    By Rob Smith in forum Excel General
    Replies: 2
    Last Post: 04-11-2005, 02: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