+ Reply to Thread
Results 1 to 38 of 38

[SOLVED] Activating Excel Template .xlt

  1. #1
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    [SOLVED] Activating Excel Template .xlt

    I am trying to figure out how to get a template workbook to activate using macros.

    I have used this in the past...

    
    Please Login or Register  to view this content.

    ...but this does not work because the .xlt file always opens up with a new name, ie. MacroTemplate.xlt would open as MacroTemplate1.xlt if opened the first time, and the number would go up each time it is opened until Excel has been restarted.

    Is there a different code that can be used or a way that I can type in the filename that it will always recognize the workbook, no matter what number is after "MacroTemplate" ...?

    I did my research but couldn't find anything, so maybe someone on here has the solution I am looking for.

    Thanks.

    -Amy Kate
    Last edited by amyxkatexx; 03-01-2010 at 12:40 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Activating Excel Template .xlt

    Something like this

    Please Login or Register  to view this content.
    This will always open the Template,not files created from it
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    I got and error that says "[Filepath] cannot be accessed."

    It goes on to say, "The file may be read-only, or you may be trying to access a read-only location. Or, the server the document is stored on may not be responding."

    The workbook is not protected, but it is read-only because it is an .xlt file.

    Is there another way to go about doing this?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Activating Excel Template .xlt

    You need to change the name to that of your template

  5. #5
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    I did. I had the whole filepath...I just shortened it when I was replying to you.

    It is in there as "Lorencz/Users/amykate/Desktop/MacroTemplate"

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Activating Excel Template .xlt

    So how have you used the code?

  7. #7
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    Well, I tried it out in a new spreadsheet, so it is all by itself right now, so no other code is messing it up.

    Please Login or Register  to view this content.

    That's how it is exactly.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Activating Excel Template .xlt

    That defines the Path not the name,what is the file called?

  9. #9
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    The file is MacroTemplate.xlt and it exists in Lorencz/Users/amykate/Desktop

    Don't I need to specify the path somewhere?

  10. #10
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    So it works if both the file the macro is stored in and the template I am opening are in the same place (ie. Desktop), but I plan for the macro to be on my personal macro workbook in my Excel Startup folder and the template to be on my desktop, so how do I tell it where the file is?

    Here is my updated code...

    Please Login or Register  to view this content.

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Activating Excel Template .xlt

    Try this
    Please Login or Register  to view this content.

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Activating Excel Template .xlt

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  13. #13
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    Quote Originally Posted by royUK View Post
    Try this
    Please Login or Register  to view this content.
    I used this exactly, but I got an error "Variable not defined"
    Last edited by amyxkatexx; 02-15-2010 at 05:54 PM. Reason: Added Quote

  14. #14
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    Quote Originally Posted by shg View Post
    Please Login or Register  to view this content.
    I am on a Mac, will that still work?

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Activating Excel Template .xlt

    Never used a Mac. Reckon it would if that were the path to your desktop, and the path separator were correct.

  16. #16
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    None of these ideas seem to be working at all. I just keep getting error after error.

    Let me rephrase my question...

    All I need is for it to open a workbook. Before I was wanting to activate the already open template, but now that I know I can just open it, that's even better.

    The workbook is an .xlt file saved to my desktop (Lorencz/Users/amykate/Desktop) and the macro is in my Personal Macro Workbook in my Excel Startup folder (Lorencz/Applications/Microsoft Office 2004/Office/Startup/Excel).

    I would appreciate it if the full code could be posted instead of a piece, so that I know I am not pasting that piece into the wrong part of the entire macro.

    Thanks.

  17. #17
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Activating Excel Template .xlt

    Take a breath, Amy.

    How about posting the code you have, and explain where it errors?

    I got an error "Variable not defined"
    Because you don't declare your variables, and Option Explicit requires that you do (and you should).

  18. #18
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    Sorry, I am not trying to come off as ungrateful, I am just simply frustrated...not at you or anyone on here, but excel in general has me quite flustered right about now.

    I did edit that reply about the error to include the quote of the code I was given that is exactly how I placed it in my module.
    Last edited by amyxkatexx; 02-15-2010 at 06:08 PM.

  19. #19
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Activating Excel Template .xlt

    What code are you using now, Amy?

  20. #20
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    Please Login or Register  to view this content.
    Last edited by shg; 02-15-2010 at 06:03 PM.

  21. #21
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Activating Excel Template .xlt

    OK, and you get a compile error, right? What is highlighted when that happens?

    ... and please stop quoting my posts ...

  22. #22
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    Please Login or Register  to view this content.
    is highlighted

  23. #23
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Activating Excel Template .xlt

    'Tis true, VBA is different on Mac than PC.

    First, you haven't declared variable sExt.

    Second, you use it before you initialize it.

    Try this (which wouldn't work on a PC, because a path requires a drive letter):
    Please Login or Register  to view this content.
    Last edited by shg; 02-15-2010 at 06:25 PM.

  24. #24
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    This is what I got...

    Run-time error '1004':

    'Lorencz/Users/amykate/Desktop/MacroTemplate.xlt' could not be found. Check the spelling of the file name, and verify that the file location is correct.

    If you are trying to open the file from your list of most recently used files on the File menu, make sure that the file has not been renamed or moved, or deleted.


    When I clicked debug, the line
    Please Login or Register  to view this content.

    is highlighted.

  25. #25
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Activating Excel Template .xlt

    Back to the fact that I've never used a Mac ...

    Paste the path Lorencz/Users/amykate/Desktop/MacroTemplate.xlt verbatim into a file browser -- does the file open?
    Last edited by shg; 02-15-2010 at 06:26 PM.

  26. #26
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    It does without the Lorencz in front of it, but I've tried it both with and without that and I still get the same error.

  27. #27
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Activating Excel Template .xlt

    Sorry, Amy, you need a Mac person to help.

  28. #28
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Activating Excel Template .xlt

    Jump in here, T.

  29. #29
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    I had gotten it to work at one point with this code...

    Please Login or Register  to view this content.

    But, that required the template and the file in which the macro was stored in to be in the same place.

    Would you have any idea how to edit this code? It works...just needs something added.

  30. #30
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    Well, I decided to compromise and just put the template in the startup folder because I usually don't need to access it much except when I am running this macro.

    It isn't perfect, but it works.

    If anyone else does have a fix, I'd be up to try it.

    Thanks so much shg and royUK for all your help!

    -Amy Kate

  31. #31
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Activating Excel Template .xlt

    Don't give up. mikerickson or romperstomper can give you an answer.

  32. #32
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Activating Excel Template .xlt

    Might help if you had stated the the fact that you are using a Mac. This might work,but I haven't used a mac
    Please Login or Register  to view this content.

  33. #33
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Activating Excel Template .xlt

    One problem is that the routine uses sExt to build the path string before sExt has been assigned a value.

    This worked on my Mac
    Please Login or Register  to view this content.
    To find your sPath constant, you can use
    Please Login or Register  to view this content.
    and remove the last ":"

    Or you could try

    Please Login or Register  to view this content.
    Last edited by mikerickson; 02-16-2010 at 10:45 AM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  34. #34
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    Please Login or Register  to view this content.

    Using that code, I get the following error:

    'MacroTemplate.xlt' cannot be accessed.

    The file may be read-only, or you may be trying to access a read-only location. Or, the server the document is stored on may not be responding.


    When I click Cancel and Debug, the part in bold up above is what is highlighted.

    Any ideas as to why?

  35. #35
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Activating Excel Template .xlt

    Are you sure that MacroTemplate.xlt is on the Desktop. Mine are automaticly put in the Template folder, unless I specify a different location.

    Also, have you tried
    Please Login or Register  to view this content.
    (The failed example in the OP used .xls extention)

  36. #36
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    It is definitely on the desktop. I always click the template type when I am saving, then go to where I want it saved. Also, I only have 3 things on my desktop, so I see it there.

    I have tried that second code; however, that only works if both the template and the macro that is being run are in the same location and that is not the case because my macro is on my personal macro workbook in my excel startup folder.

    I had it working fine with the code royUK provided
    Please Login or Register  to view this content.

    but like I said earlier, it just requires that they both be in the same location, which is alright, I guess. I just put the template in the startup folder and it worked, but I'd really prefer the template to be on my desktop.

  37. #37
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Activating Excel Template .xlt

    Try this,
    Please Login or Register  to view this content.
    Then, if it opens the template properly, you can copy from A1 to paste into

    Please Login or Register  to view this content.

  38. #38
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Activating Excel Template .xlt

    Oh my goodness! You are amazing! You totally got it!

    And that code is so much simpler than this other stuff too!

    Wow, thank you so much!

    Thank you to everyone who helped out as well.

    This was definitely a learning experience for me.

    :]

    -Amy Kate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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