none
Changing Data in Table makes Chart move in PowerPoint RRS feed

  • Question

  • Hello, 

    I have a PowerPoint 2010 Presentation. 

    On one of the the slides I have a Excel-Chart. This Excel-Chart (not linked to an Excel-File) is perfectly positioned concerning to other objects of my slide.

     

    From Word VBA I have to change some values for the Chart in PowerPoint with the following code: 

    oPPTPres.slides(1).Shapes(diagrammshape).OLEFormat.Object.sheets(2).Range("b2").Value = 20 

    This works without any Problem.... 

    BUT:
    After the value ist changed, the Chart changed in Position an in Dimension (left, top) a little bit. 

    I tried to "rembember" the dimension of the original shape und to reset it afterwards,.... but this didn't help really. 

    Any ideas? 

    Thank you very much. 

    Gernot

    Sunday, April 7, 2013 3:20 PM

Answers

  • Hi Gernot,

    Thank you for your last reply.

    I've adapted your code. The below macro will work for you.

    Public Sub Test()
        
        Dim sli As Slide
        Set sli = Application.Presentations(1).Slides(1)
        Dim index As Integer
        index = Finde_Diagramm(1)
        
        Dim shpHeight As Single
        Dim shpWidth As Single
        Dim shpTop As Single
        Dim shpLeft As Single
        shpHeight = sli.Shapes(index).Height
        shpWidth = sli.Shapes(index).Width
        shpTop = sli.Shapes(index).Top
        shpLeft = sli.Shapes(index).Left
        
        With sli.Shapes(index)
            
            .OLEFormat.Object.sheets(2).Range("c2").Value = 10 / 100
            .OLEFormat.Object.sheets(2).Range("b3").Value = 20 / 100
            .OLEFormat.Object.sheets(2).Range("c3").Value = 30 / 100
            .OLEFormat.Object.sheets(2).Range("b5").Value = 40 / 100
            .OLEFormat.Object.sheets(2).Range("c5").Value = 50 / 100
            .OLEFormat.Object.sheets(2).Range("b6").Value = 60 / 100
            .OLEFormat.Object.sheets(2).Range("c6").Value = 70 / 100
            .OLEFormat.Object.sheets(2).Range("b7").Value = 80 / 100
            .OLEFormat.Object.sheets(2).Range("c7").Value = 90 / 100
            .OLEFormat.Object.sheets(2).Range("b8").Value = 10 / 100
            .OLEFormat.Object.sheets(2).Range("c8").Value = 20 / 100
            .OLEFormat.Object.sheets(2).Range("b9").Value = 30 / 100
            .OLEFormat.Object.sheets(2).Range("c9").Value = 40 / 100
            .OLEFormat.Object.sheets(2).Range("b10").Value = 50 / 100
            .OLEFormat.Object.sheets(2).Range("c10").Value = 60 / 100
            .OLEFormat.Object.sheets(2).Range("b11").Value = 70 / 100
            .OLEFormat.Object.sheets(2).Range("c11").Value = 80 / 100
        End With
        
    
        MsgBox "Done"
        sli.Shapes(index).Height = shpHeight
        sli.Shapes(index).Width = shpWidth
        sli.Shapes(index).Top = shpTop
        sli.Shapes(index).Left = shpLeft
        
         
    End Sub

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, April 11, 2013 4:07 AM
    Moderator

All replies

  • Hi Gernot,

    Thank you for posting in the MSDN Forum.

    Could you please create a sample project with all your code and upload it to SkyDrive?

    I'm a little confused on "On one of the the slides I have a Excel-Chart. This Excel-Chart (not linked to an Excel-File)".

    I look forward to your reply.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, April 9, 2013 1:43 PM
    Moderator
  • Hi Quist,

    thank you very much for your proposed help.

    I upload a test.pptm-File to: http://sdrv.ms/10MgL1E

    There is only one slide with one graph on it. On the top, there is a Command-Button "Test".

    Click this button and you will instandly see, what I mean.

    Once again: thank you very much.

    Greeting from Germany

    Gernot

    Wednesday, April 10, 2013 8:26 PM
  • Hi Gernot,

    Thank you for your last reply.

    I've adapted your code. The below macro will work for you.

    Public Sub Test()
        
        Dim sli As Slide
        Set sli = Application.Presentations(1).Slides(1)
        Dim index As Integer
        index = Finde_Diagramm(1)
        
        Dim shpHeight As Single
        Dim shpWidth As Single
        Dim shpTop As Single
        Dim shpLeft As Single
        shpHeight = sli.Shapes(index).Height
        shpWidth = sli.Shapes(index).Width
        shpTop = sli.Shapes(index).Top
        shpLeft = sli.Shapes(index).Left
        
        With sli.Shapes(index)
            
            .OLEFormat.Object.sheets(2).Range("c2").Value = 10 / 100
            .OLEFormat.Object.sheets(2).Range("b3").Value = 20 / 100
            .OLEFormat.Object.sheets(2).Range("c3").Value = 30 / 100
            .OLEFormat.Object.sheets(2).Range("b5").Value = 40 / 100
            .OLEFormat.Object.sheets(2).Range("c5").Value = 50 / 100
            .OLEFormat.Object.sheets(2).Range("b6").Value = 60 / 100
            .OLEFormat.Object.sheets(2).Range("c6").Value = 70 / 100
            .OLEFormat.Object.sheets(2).Range("b7").Value = 80 / 100
            .OLEFormat.Object.sheets(2).Range("c7").Value = 90 / 100
            .OLEFormat.Object.sheets(2).Range("b8").Value = 10 / 100
            .OLEFormat.Object.sheets(2).Range("c8").Value = 20 / 100
            .OLEFormat.Object.sheets(2).Range("b9").Value = 30 / 100
            .OLEFormat.Object.sheets(2).Range("c9").Value = 40 / 100
            .OLEFormat.Object.sheets(2).Range("b10").Value = 50 / 100
            .OLEFormat.Object.sheets(2).Range("c10").Value = 60 / 100
            .OLEFormat.Object.sheets(2).Range("b11").Value = 70 / 100
            .OLEFormat.Object.sheets(2).Range("c11").Value = 80 / 100
        End With
        
    
        MsgBox "Done"
        sli.Shapes(index).Height = shpHeight
        sli.Shapes(index).Width = shpWidth
        sli.Shapes(index).Top = shpTop
        sli.Shapes(index).Left = shpLeft
        
         
    End Sub

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, April 11, 2013 4:07 AM
    Moderator