this my table contents, i wannna to print each column and their row cell
my code just print first cell:
Sub ExportDataToPowerPoint()
Dim pptApp As Object
Dim pptPres As Object
Dim pptSlide As Object
Dim ws As Worksheet
Dim tbl As ListObject
Dim row As ListRow
Dim colIndex As Integer
Dim colNames As Variant
Dim slideText As String
' Set the worksheet containing the data
Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to the name of your sheet
Set tbl = ws.ListObjects(1) ' Change to the name of your table if necessary
' Column names to be used in the slides
colNames = Array("نوع المنظمة", "اسم المنظمة ( يرجى إدخال اسم المنظمة باللغة العربية )", "تصنيف المنظمة", "رقم التسجيل", "رقم التسجيل معدل", "المنطقة", "المدينة", "رقم جوال المنظمة", "رقم جوال آخر", "البريد الإلكتروني للمنظمة", "بريد الكتروني آخر", "الموقع الإلكتروني")
' Start PowerPoint
On Error Resume Next
Set pptApp = GetObject(Class:="PowerPoint.Application")
If pptApp Is Nothing Then Set pptApp = CreateObject(Class:="PowerPoint.Application")
On Error GoTo 0
' Add a new presentation
Set pptPres = pptApp.Presentations.Add
' Add a new slide for the first row in the table
Set pptSlide = pptPres.Slides.Add(1, 1) ' 1 stands for ppLayoutText
pptSlide.Shapes.Title.TextFrame.TextRange.Text = "Organization Information"
slideText = ""
For colIndex = 1 To UBound(colNames) + 1
slideText = slideText & colNames(colIndex - 1) & ": " & tbl.ListRows(1).Range.Cells(1, colIndex).Value & vbCrLf
Next colIndex
With pptSlide.Shapes.Placeholders(2).TextFrame.TextRange
.Text = slideText
.Font.Name = "Arial" ' Ensure using a font that supports Arabic
End With
' Show PowerPoint
pptApp.Visible = True
' Release memory
Set pptSlide = Nothing
Set pptPres = Nothing
Set pptApp = Nothing
End Sub
my expectations to print like this “نوع المنظمة: مؤسسة
اسم المنظمة: المؤسسة الخيرية الوالدة الأمير ثامر بن عبدالعزيز
تصنيف المنظمة: الخدمات الاجتماعية
7 رقم التسجيل:
2007 رقم التسجيل معدل:
المنطقة: منطقة مكة المكرمـة
المدينة: جدة
553303844 رقم الجوال:
رقم جوال آخر:
[email protected] البريد الإلكتروني:
البريد الإلكتروني آخر:
mptf.org.sa الموقع الإلكتروني: “
Najlaa Alnabati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.