Removing specific pre-existing PowerPoint chart with officer

29 views Asked by At

I have a specific PowerPoint file which contains a chart on the third slide. My goal is to delete and replace it with another one. The problem I'm facing is that officer::ph_delete is apparently not removing the old chart.

Third slide summary
slide_summary(read_pptx('Google Mobility.pptx'), index = 3)

type id ph_label      offx      offy       cx       cy rotation fld_id fld_type text
1 body  2 Imagem 6 0.6666557 0.2499923 12.00002 7.000013       NA   <NA>     <NA>
1st attempt

My first try was the following. This apperantly runs ok (i.e., don't return an error) but in fact don't delete the chart.

 read_pptx('Google Mobility.pptx') %>% 
    on_slide(index = 3) %>% 
    ph_remove(ph_label = "Imagem 6") %>% 
    print('Google Mobility.pptx')
2nd attempt

My second try uses id = 2 inside ph_remove() but now I get an error message.

  read_pptx('Google Mobility.pptx') %>% 
    on_slide(index = 3) %>% 
    ph_remove(ph_label = "Imagem 6", id = 2) %>% 
    print('Google Mobility.pptx')

Error in get_shape_id(x, type = type, id = id, ph_label = ph_label) : 
  no shape with label "Imagem 6"and with id 2 has been found

Thanks in advance for any help!

0

There are 0 answers