vba Application.CommandBars.ExecuteMso(“PasteSourceFormatting”)在 powerpoint 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19731131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Application.CommandBars.ExecuteMso ("PasteSourceFormatting") does not work in powerpoint
提问by Alvin Jing
I tried to use vba in powerpoint to copy a table from excel to powerpoint, then resize it in powerpoint. However, it prompts out the error "Selection(Unknown number)". If I save it before resizing, it will work ok. But I don't want to save it. How to solve this issue? Below is my code:
我尝试在powerpoint中使用vba将表格从excel复制到powerpoint,然后在powerpoint中调整它的大小。但是,它提示错误“选择(未知数)”。如果我在调整大小之前保存它,它会正常工作。但我不想保存它。如何解决这个问题?下面是我的代码:
sld.Select
sld.Application.Activate
ActiveWindow.Application.CommandBars.ExecuteMso "PasteExcelChartSourceFormatting"
sld.Application.CommandBars.ExecuteMso ("PasteSourceFormatting")
'sld.Application.ActivePresentation.Save
With ActiveWindow.Selection.ShapeRange
.Height = 7.3 * 72
.Width = 13.38 * 72
.Left = 1.45 * 72
.Top = 1.35 * 72
.ZOrder msoSendToBack
End With
Best, Alvin
最好的,阿尔文
回答by user2847768
Alvin,
阿尔文,
I too encountered this issue. You need to release focus from the commandbars to fix the error. Try adding this below the ExecuteMso line:
我也遇到了这个问题。您需要从命令栏中释放焦点以修复错误。尝试在 ExecuteMso 行下方添加以下内容:
sld.Application.CommandBars.ReleaseFocus
Hope this helps.
希望这可以帮助。