我有这个代码片段可以正常工作,除了当我尝试将文本对齐到中心时的最后一行。msoAlignRight 只是为了测试目的,看看它是否向右移动..但没有任何反应。- 编辑:我已经将它从 Qlikview 合并到 PPT 宏中,不过应该没关系。
注意:我希望 leText 0 在中间居中。现在它在左边。
Sub ppt
'Set ppt template
filePath_template = "...\Template.pptx"
'Remove filters
ActiveDocument.ClearAll()
'Retrieve all accounts
set field1Values = ActiveDocument.Fields("name").GetPossibleValues
ActiveDocument.ActivateSheetByID "ABC01"
for i = 0 to 15
ActiveDocument.Fields("name").Clear
ActiveDocument.GetApplication.WaitForIdle 100
'Set filter on just 1 account
ActiveDocument.Fields("name").Select field1Values.Item(i).Text
ActiveDocument.GetApplication.Sleep 5000
ActiveDocument.GetApplication.WaitForIdle 100
'Create a ppt object
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
'Open the ppt template
Set objPresentation = objPPT.Presentations.Open(filePath_template)
Set PPSlide = objPresentation.Slides(1)
'leText 2
ActiveDocument.GetSheetObject("TEXT001").CopyTextToClipboard
ActiveDocument.GetApplication.WaitForIdle 100
Set leText2 = PPSlide.Shapes.Paste
leText2.Top = 280
leText2.Left = 310
leText2.Width = 300
leText2.TextFrame.TextRange.Font.Size = 8
ActiveDocument.GetApplication.Sleep 1000
for k = 0 to 10
ActiveDocument.GetApplication.WaitForIdle 100
ActiveDocument.ActiveSheet.CopyBitmapToClipboard
ActiveDocument.GetApplication.WaitForIdle 100
next
ActiveDocument.GetApplication.WaitForIdle 100
'leText 0
ActiveDocument.GetSheetObject("TEXT002").CopyTextToClipboard
ActiveDocument.GetApplication.WaitForIdle 100
Set leText0 = PPSlide.Shapes.Paste
leText0.Top = 1
leText0.Left = 150
leText0.Width = 700
leText0.TextFrame.TextRange.Font.Size = 12
leText0.TextFrame.TextRange.Font.Color = vbWhite
'Save ppt
filePath = "...\SaveFolder\" & field1Values.Item(i).Text & ".pptx"
objPresentation.SaveAs filePath
Next
objPPT.Quit
End Sub