UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> VBA Code Transfer Chart In Access To Ppt Error On Win10, Access 2016    
 
   
antonyel
post Jan 6 2018, 04:43 AM
Post#1



Posts: 4
Joined: 25-December 17



Hi Guru..

I did some access database and transfer Chart in FORM (96 Charts) on to PPT Slide. the problem is this access tools quite stable on WIN7 (No ERROR at all) once I used in my new laptop Windows 10 is not Stable (some time OK) i did export all the chart to the PPT Slide, sometimes I facing some error in the middle or randomly page.. like page 17, 35, 39 88, 91 the pattern not so clear
the error also not soo clear sometime error run time 2225.

could anyone help to see whether somethink wrong or any required information do i need to add extra code when i used this tools in window 10.
this is the code i used :

i had tried to used error code hendler by resume next but the result some of the page is missing on the PPT Slide.
many thanks

Private Sub BtnExportToPPT_Click()
Dim powerpoint As powerpoint.Application
Dim x As Integer, SlideNo As Integer
On Error GoTo ErrorHandler
On Error Resume Next



SlideNo = 5
Set powerpoint = CreateObject("PowerPoint.Application")
powerpoint.Visible = True
powerpoint.Presentations.Open ("C:\Generate Report\Report.pptx")
DoCmd.Echo False
For x = 0 To Me.Controls.Count - 1
If Me.Controls(x).ControlType = 113 Then '"MSGraph.Chart"
Me.Controls(x).SetFocus
DoCmd.RunCommand acCmdCopy
DoEvents
powerpoint.ActiveWindow.Presentation.Slides(SlideNo).Shapes.PasteSpecial ppPasteEnhancedMetafile
powerpoint.ActiveWindow.Presentation.Slides(SlideNo).Shapes.Item(3).Line.ForeCol
or.RGB = vbBlack
powerpoint.ActiveWindow.Presentation.Slides(SlideNo).Shapes.Item(3).Line.Weight = 1.5
powerpoint.ActiveWindow.Presentation.Slides(SlideNo).Shapes.Item(3).Line.Visible = True
SlideNo = SlideNo + 1
powerpoint.ActivePresentation.Slides(SlideNo).Duplicate
DoEvents
End If
Next
powerpoint.ActivePresentation.Slides(SlideNo).Delete
DoCmd.Echo True
MsgBox "Hi... Generate Report To PowerPoint has Finish!!! Enjoy....."
Exit Sub
ErrorHandler:
Err.Number = vbObjectError + 1052
End Sub
Go to the top of the page
 
DanielPineault
post Jan 6 2018, 07:12 AM
Post#2


UtterAccess VIP
Posts: 6,068
Joined: 30-June 11



When you debug the error, which line is being flagged as the issue?

Also, based on the error message
QUOTE
Microsoft Office Access couldn't open the Clipboard.@The Clipboard isn't responding, probably because another application is using it. Close all other applications and try the operation again

This sounds like the loop simply going too fast. I'd probably start by trying to slow down the process ever so slightly by adding either DoEvents or some type of minute pause at that point.

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
JonSmith
post Jan 6 2018, 09:19 AM
Post#3



Posts: 3,838
Joined: 19-October 10



So your error handling is kind of messed up.

CODE
On Error GoTo ErrorHandler
On Error Resume Next


So the first line tells it then when it hits an error goto the label ErrorHandler at the bottom of your sub. Next line overrules this instruction and says when it hits an error ignore it and move to the next line (so suppressing all errors).

Next the error handler itself is kind of strange I think?
CODE
ErrorHandler:
Err.Number = vbObjectError + 1052
End Sub

This would always return the same error code making it never give a useful error?

I'd suggest removing all that error handling for now, this some make it debug on the line causing the issue and also give you an accurate error number and description (we need the desc as we cannot remember the numbers all the time, we aren't robots tongue.gif)
Where did you get that error handling from? I think it would benefit you to get some help on redoing it once this issue is solved to get a better understanding and implement good error handling.


On a slight side note. I googled VBA error 2225 and was amazed to find that some of the top hits were articles about 'VBA error handling error' were articles purporting that these errors are usually down to configuration issues and download this registry fixer, then this spyware scanner etc etc, you know the deal, install all our dodgy scanning software. Pretty bad how prevalent the taking advantage of vulnerable people these things do.
Go to the top of the page
 
antonyel
post Jan 6 2018, 11:41 AM
Post#4



Posts: 4
Joined: 25-December 17



HI all

thanks for the suggestion, i have solved the issue so basically i did check the error seems its random error and can be identified the pattern, so I decided used the error handling

on error goto err1

exit sub

err1:
X = X - 0
resume

so everytime error event trigger, it will just back to previous steps and copy the left Chart, and keep continuing through the next chart until finished
now it run perfectly on win10



Go to the top of the page
 
JonSmith
post Jan 7 2018, 11:14 AM
Post#5



Posts: 3,838
Joined: 19-October 10



Personally I would say that its suppressed rather than solved and would want to find the actual cause and then solve it.
If you are happy though then oke.

JS
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    24th September 2018 - 11:15 AM