-
Format chiều cao (Height) table trong Power Point
Minh Tiên > 09-06-21, 03:17 PM
Nhờ cả nhà giúp đỡ:
Tiên đã mày mò code VBA làm việc với file Power Point có sẳn từ Access như: Thêm, sửa, xóa, format các Shape, Table, ... đều OK. Nhưng để format chiều cao (Height) cho 1 table trong 1 trình chiếu thì không sao làm được (Không phải format từng dòng (row) trong table).
Nhờ cả nhà giúp đoạn code Format Height Table.
Đoạn code làm việc với file Power Point:
Mã:Private Sub FormatTable()
Dim sFile As String
sFile = CurrentProject.Path & "\" & "TenSlide.pptx"
Dim ppApp As Object
Dim ppPres As Object
Dim ppSlide As Object
Dim oeff As Object
On Error Resume Next
Set ppApp = GetObject(, "PowerPoint.Application")
If Err.Number <> 0 Then
Err.Clear
Set ppApp = CreateObject("PowerPoint.Application")
End If
ppApp.Visible = False
Set ppPres = ppApp.Presentations.Open(FileName:=sFile, WithWindow:=msoTrue)
Set ppSlide = ppPres.Slides(1)
With ppSlide.Shapes(1).Table
'Ghi thông tin vào table:
.Cell(1, 1).Shape.TextFrame.TextRange.text = "Hello" 'Chạy OK
'Format chiều cao cho dòng 1:
.Rows(1).Height = 50 ' Chạy OK
'Format chiều cao cho cả Table:
.Height = 500 'Không format được. Nhờ ACE chỉ giúp đoạn này.
End With
ppPres.Save
' ppPres.Close
' ppApp.Quit
Set ppApp = Nothing
Set ppPres = Nothing
Set ppCurrentSlide = Nothing
End Sub
Cảm ơn nhiều ! -
RE: Format chiều cao (Height) table trong Power Point
ongke0711 > 09-06-21, 04:44 PM
Không thiết lập Height ở Table mà ở Shape.
Mã PHP:ppSlide.Shapes(1).Height = 300