Page 1 of 1
copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Wed Aug 29, 2018 12:16 pm
by March201711
ถ้าเราจะ copy จาก file excel ไป paste picture ที่ file ใหม่เป็น file powerpoint เราสามารถทำได้ไหมค่ะ ลอง record marco แล้วทำ ไม่ได้น่ะค่ะ เพราะต้องทำเป็นประจำทุกวันค่ะ
Re: copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Wed Aug 29, 2018 12:17 pm
by March201711
file excel ค่ะ
Re: copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Wed Aug 29, 2018 10:37 pm
by snasui

ไม่พบ Macro ในไฟล์ที่แนบมาครับ
Re: copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Thu Aug 30, 2018 11:39 am
by March201711
แนบมาให้ใหม่ค่ะ
Re: copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Thu Aug 30, 2018 8:29 pm
by snasui

Code ที่แนบมาไม่พบว่ามีการวางข้อมูลที่ PowerPoint ลองศึกษา Code จาก Link นี้ครับ
https://www.thespreadsheetguru.com/blog ... t-with-vba
Re: copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Thu Aug 30, 2018 9:06 pm
by March201711
ลองทำแล้วค่ะ แต่ติดปัญหาการดึงเปิดfile ของ powerpoint อยากให้ดึงfileที่เก็บไว้ที่ drive c ชื่อ test2 ต้องปรับแก้ code vba อย่างไรคะ
Re: copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Thu Aug 30, 2018 9:33 pm
by snasui

ตัวอย่างการปรับ Code ครับ
Code: Select all
'Other code
'If PowerPoint is not already open then open PowerPoint
If PowerPointApp Is Nothing Then Set PowerPointApp = CreateObject(class:="PowerPoint.Application")
myDestination = "C:\Test2.pptx"
Set myPresentation = PowerPointApp.Presentations.Open(myDestination)
'Handle if the PowerPoint Application is not found
If Err.Number = 429 Then
MsgBox "PowerPoint could not be found, aborting."
Exit Sub
End If
On Error GoTo 0
'Optimize Code
Application.ScreenUpdating = False
'Create a New Presentation
' Set myPresentation = PowerPointApp.Presentations.Add
'Add a slide to the Presentation
Set mySlide = myPresentation.Slides(1) '.Add(1, 11) '11 = ppLayoutTitleOnly
'Other code
Re: copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Thu Aug 30, 2018 9:58 pm
by March201711
ลองแล้วค่ะ ไม่ได้ มันเปิดเป็น powerpoint ให้ใหม่เลยค่ะ
ปล. ขอเปลี่ยนที่ย้ายเป็นที่ drive D นะค่ะ เพราะ drive cfileเยอะหาไม่เจอค่ะ
Re: copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Thu Aug 30, 2018 10:07 pm
by snasui

Code ในไฟล์ล่าสุดไม่ตรงกับที่ผมแก้ไขไปให้ครับ
Re: copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Thu Aug 30, 2018 10:22 pm
by March201711
ได้แล้วค่ะ

แต่ถามนิดนึงค่ะ ถ้าจะให้ภาพที่นำมาวางใน powerpoint ให้พอดีกับทั้งขอบบนและล่าง ซ้ายและขวา ต้องปรับอย่างไรคะ
Re: copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Thu Aug 30, 2018 10:39 pm
by snasui

กรุณาปรับมาเองก่อน ติดแล้วค่อยถามกันต่อครับ
Re: copy แล้วไปวางที่ file powerpoint โดยใช้มาโคร
Posted: Fri Aug 31, 2018 5:52 pm
by March201711
ได้แล้วค่ะ ขอบคุณอาจารย์มากค่ะ