Is it possible to add a new workbook based on a locked template The Next CEO of Stack OverflowAdd Workbook based on TemplateAdding new Workbook in VBA crashes Excel 2013Disable Password Prompt when opening workbook through VBACheck if workbook in SharePoint 365 is locked for editingExcel 2013 VBA wsheet.protect UserInterfaceOnly:=TrueCannot open new workbooks while a certain workbook is openOpen html file with Workbooks.Open allways in new workbookSaving new Excel document as macro-free workbook without promptAdd userform to a different workbook at runtimeExcel VBA: Create new workbooks from template based on sheet with data

The exact meaning of 'Mom made me a sandwich'

Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?

Legal workarounds for testamentary trust perceived as unfair

What does "Its cash flow is deeply negative" mean?

How to prove a simple equation?

Is it professional to write unrelated content in an almost-empty email?

If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?

Are police here, aren't itthey?

Is it convenient to ask the journal's editor for two additional days to complete a review?

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

How to avoid supervisors with prejudiced views?

Where do students learn to solve polynomial equations these days?

Is it possible to use a NPN BJT as switch, from single power source?

Does increasing your ability score affect your main stat?

Why does standard notation not preserve intervals (visually)

WOW air has ceased operation, can I get my tickets refunded?

Can you be charged for obstruction for refusing to answer questions?

Which one is the true statement?

Is there a way to save my career from absolute disaster?

Solving system of ODEs with extra parameter

Why is my new battery behaving weirdly?

Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?

Why the difference in type-inference over the as-pattern in two similar function definitions?

Some questions about different axiomatic systems for neighbourhoods



Is it possible to add a new workbook based on a locked template



The Next CEO of Stack OverflowAdd Workbook based on TemplateAdding new Workbook in VBA crashes Excel 2013Disable Password Prompt when opening workbook through VBACheck if workbook in SharePoint 365 is locked for editingExcel 2013 VBA wsheet.protect UserInterfaceOnly:=TrueCannot open new workbooks while a certain workbook is openOpen html file with Workbooks.Open allways in new workbookSaving new Excel document as macro-free workbook without promptAdd userform to a different workbook at runtimeExcel VBA: Create new workbooks from template based on sheet with data










1















I've got the following VBA code which Adds a new workbook based on a template.



Option Explicit

Public Sub AddTemplatedWB()
Workbooks.Add ( _
"C:VssBOXGeneric ProjectsPMC2template.xlsm" _
)
End Sub


This works except when the template is locked. Then I get the usual password prompt:



enter image description here



Clicking Cancel gives me an error in VBA:



enter image description here



Is there any way to supply the password directly when adding the workbook? (This seems particularly weird since you can supply a password when Opening a file.)



If not, is there any other way to achieve what I'm looking for, i.e. creating a new file in memory based on a locked file?










share|improve this question




























    1















    I've got the following VBA code which Adds a new workbook based on a template.



    Option Explicit

    Public Sub AddTemplatedWB()
    Workbooks.Add ( _
    "C:VssBOXGeneric ProjectsPMC2template.xlsm" _
    )
    End Sub


    This works except when the template is locked. Then I get the usual password prompt:



    enter image description here



    Clicking Cancel gives me an error in VBA:



    enter image description here



    Is there any way to supply the password directly when adding the workbook? (This seems particularly weird since you can supply a password when Opening a file.)



    If not, is there any other way to achieve what I'm looking for, i.e. creating a new file in memory based on a locked file?










    share|improve this question


























      1












      1








      1








      I've got the following VBA code which Adds a new workbook based on a template.



      Option Explicit

      Public Sub AddTemplatedWB()
      Workbooks.Add ( _
      "C:VssBOXGeneric ProjectsPMC2template.xlsm" _
      )
      End Sub


      This works except when the template is locked. Then I get the usual password prompt:



      enter image description here



      Clicking Cancel gives me an error in VBA:



      enter image description here



      Is there any way to supply the password directly when adding the workbook? (This seems particularly weird since you can supply a password when Opening a file.)



      If not, is there any other way to achieve what I'm looking for, i.e. creating a new file in memory based on a locked file?










      share|improve this question
















      I've got the following VBA code which Adds a new workbook based on a template.



      Option Explicit

      Public Sub AddTemplatedWB()
      Workbooks.Add ( _
      "C:VssBOXGeneric ProjectsPMC2template.xlsm" _
      )
      End Sub


      This works except when the template is locked. Then I get the usual password prompt:



      enter image description here



      Clicking Cancel gives me an error in VBA:



      enter image description here



      Is there any way to supply the password directly when adding the workbook? (This seems particularly weird since you can supply a password when Opening a file.)



      If not, is there any other way to achieve what I'm looking for, i.e. creating a new file in memory based on a locked file?







      excel vba






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 20 at 10:01







      Anton Lahti

















      asked Mar 20 at 9:36









      Anton LahtiAnton Lahti

      606




      606






















          2 Answers
          2






          active

          oldest

          votes


















          1














          This code should work for you, since you can supply the password during the call:



          Public Sub AddTemplatedWB()
          Workbooks.Open Filename:="C:VssBOXGeneric ProjectsPMC2template.xlsm", _
          Password:="YourPassword"
          End Sub



          Edit:



          I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password.




          One possible solution that pops to my mind is to create a copy of the
          template and then opening it.







          share|improve this answer

























          • No, this opens the template. I want a new workbook based on a template.

            – Anton Lahti
            Mar 20 at 10:08






          • 2





            I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password. One possible solution that pops to my mind is to create a copy of the template and then opening it.

            – Louis
            Mar 20 at 10:53












          • Can you accept my answer, since you used my solution to solve the issue? Thank you.

            – Louis
            Mar 21 at 18:04


















          0














          No, there doesn't seem to be any way to do this.



          What I ended up doing instead is copying the template to a temporary file, Opening with the password.
          Then I made sure that the temporary file was deleted after I was done with it.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55257597%2fis-it-possible-to-add-a-new-workbook-based-on-a-locked-template%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            This code should work for you, since you can supply the password during the call:



            Public Sub AddTemplatedWB()
            Workbooks.Open Filename:="C:VssBOXGeneric ProjectsPMC2template.xlsm", _
            Password:="YourPassword"
            End Sub



            Edit:



            I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password.




            One possible solution that pops to my mind is to create a copy of the
            template and then opening it.







            share|improve this answer

























            • No, this opens the template. I want a new workbook based on a template.

              – Anton Lahti
              Mar 20 at 10:08






            • 2





              I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password. One possible solution that pops to my mind is to create a copy of the template and then opening it.

              – Louis
              Mar 20 at 10:53












            • Can you accept my answer, since you used my solution to solve the issue? Thank you.

              – Louis
              Mar 21 at 18:04















            1














            This code should work for you, since you can supply the password during the call:



            Public Sub AddTemplatedWB()
            Workbooks.Open Filename:="C:VssBOXGeneric ProjectsPMC2template.xlsm", _
            Password:="YourPassword"
            End Sub



            Edit:



            I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password.




            One possible solution that pops to my mind is to create a copy of the
            template and then opening it.







            share|improve this answer

























            • No, this opens the template. I want a new workbook based on a template.

              – Anton Lahti
              Mar 20 at 10:08






            • 2





              I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password. One possible solution that pops to my mind is to create a copy of the template and then opening it.

              – Louis
              Mar 20 at 10:53












            • Can you accept my answer, since you used my solution to solve the issue? Thank you.

              – Louis
              Mar 21 at 18:04













            1












            1








            1







            This code should work for you, since you can supply the password during the call:



            Public Sub AddTemplatedWB()
            Workbooks.Open Filename:="C:VssBOXGeneric ProjectsPMC2template.xlsm", _
            Password:="YourPassword"
            End Sub



            Edit:



            I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password.




            One possible solution that pops to my mind is to create a copy of the
            template and then opening it.







            share|improve this answer















            This code should work for you, since you can supply the password during the call:



            Public Sub AddTemplatedWB()
            Workbooks.Open Filename:="C:VssBOXGeneric ProjectsPMC2template.xlsm", _
            Password:="YourPassword"
            End Sub



            Edit:



            I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password.




            One possible solution that pops to my mind is to create a copy of the
            template and then opening it.








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 21 at 18:02

























            answered Mar 20 at 10:02









            LouisLouis

            30329




            30329












            • No, this opens the template. I want a new workbook based on a template.

              – Anton Lahti
              Mar 20 at 10:08






            • 2





              I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password. One possible solution that pops to my mind is to create a copy of the template and then opening it.

              – Louis
              Mar 20 at 10:53












            • Can you accept my answer, since you used my solution to solve the issue? Thank you.

              – Louis
              Mar 21 at 18:04

















            • No, this opens the template. I want a new workbook based on a template.

              – Anton Lahti
              Mar 20 at 10:08






            • 2





              I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password. One possible solution that pops to my mind is to create a copy of the template and then opening it.

              – Louis
              Mar 20 at 10:53












            • Can you accept my answer, since you used my solution to solve the issue? Thank you.

              – Louis
              Mar 21 at 18:04
















            No, this opens the template. I want a new workbook based on a template.

            – Anton Lahti
            Mar 20 at 10:08





            No, this opens the template. I want a new workbook based on a template.

            – Anton Lahti
            Mar 20 at 10:08




            2




            2





            I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password. One possible solution that pops to my mind is to create a copy of the template and then opening it.

            – Louis
            Mar 20 at 10:53






            I was looking it up, but it seems that Microsoft didn't provide a direct way to do it. Maybe because they thought that it's not practical to lock a template with a password. One possible solution that pops to my mind is to create a copy of the template and then opening it.

            – Louis
            Mar 20 at 10:53














            Can you accept my answer, since you used my solution to solve the issue? Thank you.

            – Louis
            Mar 21 at 18:04





            Can you accept my answer, since you used my solution to solve the issue? Thank you.

            – Louis
            Mar 21 at 18:04













            0














            No, there doesn't seem to be any way to do this.



            What I ended up doing instead is copying the template to a temporary file, Opening with the password.
            Then I made sure that the temporary file was deleted after I was done with it.






            share|improve this answer



























              0














              No, there doesn't seem to be any way to do this.



              What I ended up doing instead is copying the template to a temporary file, Opening with the password.
              Then I made sure that the temporary file was deleted after I was done with it.






              share|improve this answer

























                0












                0








                0







                No, there doesn't seem to be any way to do this.



                What I ended up doing instead is copying the template to a temporary file, Opening with the password.
                Then I made sure that the temporary file was deleted after I was done with it.






                share|improve this answer













                No, there doesn't seem to be any way to do this.



                What I ended up doing instead is copying the template to a temporary file, Opening with the password.
                Then I made sure that the temporary file was deleted after I was done with it.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 21 at 8:59









                Anton LahtiAnton Lahti

                606




                606



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55257597%2fis-it-possible-to-add-a-new-workbook-based-on-a-locked-template%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript