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

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현