Problème macro Onedrive

Bonjour,

J'ai un problème avec un macro commande. Quand j'utilise la macro sur mon disque dur cela fonctionne. Quand je mets la macro sur Onedrive et que je l'exécute j'ai une message d'erreur.

Le message d'erreur que je reçois est : Methode de l'objet EXPORT "_Chart" a échoué

Voici la ligne de code où je reçois le message d'erreur:

ActiveSheet.ChartObjects("CommentPic").Chart.Export ThisWorkbook.Path & "\ChartPic.jpg"

Je travaille avec Excel 2016.

Merci,

Oiseau bleu

Option Explicit

Sub CreateCommentChartPic()
Dim SelRow As Long
Dim PicFileName As String
Dim PicComm As Comment
With Sheet1
            SelRow = .Range("B4").Value
            PicFileName = ThisWorkbook.Path & "\ChartPic.jpg"
            On Error Resume Next
            If Dir(PicFileName) > 0 Then Kill (PicFileName)  
            On Error GoTo 0
            .Shapes("AnnSalesChart").CopyPicture xlScreen, xlBitmap 
            'Create a new Temporary Chart
            With ActiveSheet.ChartObjects.Add(Left:=.Shapes("AnnSalesChart").Left, Top:=.Shapes("AnnSalesChart").Top, Width:=.Shapes("AnnSalesChart").Width, Height:=.Shapes("AnnSalesChart").Height)
                .Name = "CommentPic"
                .Activate
            End With

                  ActiveChart.Paste 
                  ActiveSheet.ChartObjects("CommentPic").Chart.Export ThisWorkbook.Path & "\ChartPic.jpg"
                 .Shapes("CommentPic").Delete 
                 On Error Resume Next
                 .Range("L" & SelRow).ClearComments
                 On Error GoTo 0
                 Set PicComm = .Range("L" & SelRow).AddComment
                 With PicComm
                        .Text Text:=" "
                        .Shape.Fill.UserPicture (PicFileName)
                        .Shape.ScaleHeight 2.95, msoFalse, msoScaleFromTopLeft
                        .Shape.ScaleWidth 2.32, msoFalse, msoScaleFromTopLeft
                        .Visible = True
                 End With
        End With
End Sub

Bonjour,

Je ferais un test du genre ...

Aux 2 endroits, remplace > ThisWorkbook.Path & "\ChartPic.jpg"

Par > "ChartPic.jpg"

Ainsi, ça devrait être transparent > Local et OneDrive.

ric

Bonjour,

Merci beaucoup pour votre réponse cela fonctionne.

Oiseau bleu

Rechercher des sujets similaires à "probleme macro onedrive"