|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
for ii= 0 to rs.count不好用。
只能用 Do While Not .EOF 的组合应用
.MoveNext+Loop
- Sub MovePicToShtFolder()
- ''临时文件目录的文件移到指定目录。
- Dim Rs As ADODB.Recordset
- Dim Fso As Scripting.FileSystemObject
- Set Fso = New Scripting.FileSystemObject
- Dim Sht As Worksheet, Sht1 As Worksheet
-
- Dim PathFile
- PathFile = ThisWorkbook.Path & "\t\t.ppsx"
- Dim Str, SqlStr
- Dim Rr
- Dim Ppt As PowerPoint.Application
- Dim Pres As Presentation
- Dim Sld As Slide
- Dim Shp 'As Shape
- ''
- Set Sht1 = Sheets("t")
- Str = Sht1.Cells(1, 1)
- Set Sht = ThisWorkbook.Worksheets(Str)
- Sht.Cells.Clear
- Sht.Cells.Font.Size = 9
-
- Rr = 5
-
- Set Ppt = New PowerPoint.Application
- Ppt.Visible = msoCTrue
- If Fso.FileExists(PathFile) Then
- If Ppt.Presentations.Count = 0 Then
- Set Pres = Ppt.Presentations.Open(PathFile)
- Else
- Set Pres = Ppt.Presentations(PathFile)
- End If
- Else
- MsgBox PathFile
- End If
- For Each Sld In Pres.Slides
- Str = Sld.NotesPage.Shapes.Placeholders(2).TextFrame.TextRange.Text
- 'Debug.Print Str,
- Set Shp = Sld.Shapes("Date")
- 'Debug.Print Shp.Left, Shp.Top, Shp.Width, Shp.Height
- Set Rs = EngChiSqlRs(ThisWorkbook.FullName, Str, "A1:O1000")
- With Rs
- .MoveFirst
- For jj = 0 To .Fields.Count - 2
- Sht.Cells(1, jj + 2) = .Fields(jj).Name
- 'Debug.Print .Fields(jj).Name, .Fields(jj)
- Next jj
- Sht.Cells(1, jj + 2) = "Left"
- Sht.Cells(1, jj + 3) = "Top"
- Sht.Cells(1, jj + 4) = "Width"
- Sht.Cells(1, jj + 5) = "Height"
-
- ''
- Do While Not .EOF
- For jj = 0 To .Fields.Count - 2
- Sht.Cells(Rr, jj + 2) = .Fields(jj).Value
- Next jj
-
- .MoveNext
- Loop
- With Shp
- Sht.Cells(Rr, jj + 2) = .Left
- Sht.Cells(Rr, jj + 3) = .Top
- Sht.Cells(Rr, jj + 4) = .Width
- Sht.Cells(Rr, jj + 5) = Int(.Height)
- End With
- End With
- Rr = Rr + 1
- Next Sld
-
- 'Ppt.Quit
- End Sub
复制代码 |
|