简体   繁体   English

如何使用Power-Shell在PowerPoint中应用默认主题

[英]How to apply default themes in PowerPoint using power-shell

I've been asked at work to make sure everyone has the same default theme on their PowerPoint application so that everyone is uniform and compliant. 我在工作中被要求确保每个人在其PowerPoint应用程序上都具有相同的默认主题,以便每个人都统一且合规。 Problem is i dont know how but i know Power-Shell can do that for me. 问题是我不知道如何做,但我知道Power-Shell可以为我做到这一点。 I've started on a good tip but this script did not work for me. 我从一个好的技巧开始,但是这个脚本对我不起作用。

Add-type -AssemblyName office
$Application = New-Object -ComObject powerpoint.application
$application.visible = [Microsoft.Office.Core.MsoTriState]::msoTrue

$themePath = "C:\Users\emp\AppData\Roaming\Microsoft\Templates\Document Themes\Theme1.thmx"
$path = "C:\Users\emp\AppData\Roaming\Microsoft\Templates\Document Themes"
Get-ChildItem -Path $path -Include "*.ppt", "*.pptx" -Recurse |
ForEach-Object {
 $presentation = $application.Presentations.open($_.fullname)
 $presentation.ApplyTemplate($themePath)
 $presentation.Save()
 $presentation.Close()
 "Modifying $_.FullName"
} 

$application.quit()
$application = $null
[gc]::collect()
[gc]::WaitForPendingFinalizers()

Can anyone shed any light on how to change the default theme using powershell? 谁能阐明如何使用Powershell更改默认主题? Any help would be greatly appreciated! 任何帮助将不胜感激!

You don't say what version of PowerPoint you are using. 您没有说要使用的PowerPoint版本。 Every version is a bit different than the previous one, even down to who you'd do stuff via the Object Model. 每个版本都与前一个版本有所不同,甚至取决于您将通过对象模型进行操作的对象。

In general the code you are using should solve you use case (which looks like you leveraged from here: PowerShell 101 blog or from here: Hey, Scripting Guy! How Can I Customize Microsoft PowerPoint Presentations ), but you are not saying that you are having any errors in what you are using. 通常,您正在使用的代码应该可以解决您的用例(看起来就像您在此处利用的: PowerShell 101博客或从此处利用的: 嘿,脚本专家!我如何自定义Microsoft PowerPoint演示文稿 ),但您并不是在说在使用中出现任何错误。 So what do you mean by this? 那么,这是什么意思呢?

I've started on a good tip but this script did not work for me. 我从一个好的技巧开始,但是这个脚本对我不起作用。

I am not sure why you feel PowerShell is the option to do this. 我不确定为什么您会认为PowerShell是执行此操作的选项。 Users would still have to run it for the changes to happen, or the user could just set this themselves natively in PowerPoint. 用户仍然必须运行它才能进行更改,或者用户可以只在PowerPoint中自己进行设置。

In PP2K16 they just do this: 在PP2K16中,他们只是这样做:

  1. Launch PPT 启动PPT
  2. Use File> New from Template 使用文件>从模板新建
  3. Select your template to create a new presentation 选择您的模板以创建新的演示文稿
  4. Go to the Design tab 转到设计选项卡
  5. Expand the Themes Gallery 展开主题库
  6. Select the Save Current Theme command 选择“保存当前主题”命令
  7. Name the Theme file & click Save 命名主题文件并单击保存
  8. In the Themes Gallery, right-click your thumbnail & select Set as Default Theme 在主题库中,右键单击您的缩略图,然后选择“设置为默认主题”

Sure, you could script these steps, but there is no way to block a user from using some other template they downloaded or created, modifying the template you just set or that are not already part of PowerPoint by default. 当然,您可以编写这些步骤的脚本,但是无法阻止用户使用他们下载或创建的其他模板,修改您刚刚设置的模板或默认情况下不属于PowerPoint的模板。

Simply put, you cannot technically force a user to use a given template in PowerPoint. 简而言之,您不能从技术上强迫用户在PowerPoint中使用给定的模板。 There is no setting in MSOffice / PowerPoint which allows that. MSOffice / PowerPoint中没有允许该设置的设置。

This sounds like you are trying to use technology to solve a user habit issue. 听起来您正在尝试使用技术来解决用户习惯问题。 That' s really not a thing. 那真的不是什么。 If you org has a standard, and users fail to comply, or work to circumvent it, then that is an HR issue. 如果您的组织有一个标准,而用户却没有遵守或努力规避它,那么这就是人力资源问题。

You can delete all existing templates and copy only the template you want to the default folders and use GPO to set the default. 您可以删除所有现有模板,仅将所需模板复制到默认文件夹,然后使用GPO设置默认模板。 Again this still does not stop user from adds or modifications. 同样,这仍然不会阻止用户进行添加或修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM