How to Rotate or Flip Grouped Shapes in PowerPoint using Office.js?

Here’s a description you can use for your Stack Overflow post:

Description:

I’m working on a PowerPoint add-in using Office.js and need to flip or rotate grouped shapes horizontally. However, I’m encountering some issues:

  1. Flip Functionality: I tried using shape.flip("Horizontal"), but it doesn’t seem to work for grouped shapes.
  2. Rotation Property: When attempting to access or set the rotation property, I get undefined or NaN.

Here’s a simplified version of the code I’m working with:

PowerPoint.run(async (context) => {
    const slide = context.presentation.slides.getActiveSlide();
    const selectedShapes = slide.shapes.getSelected();
    selectedShapes.load("id,name,type,width,height,left,top");

    await context.sync();

    selectedShapes.items.forEach(shape => {
        console.log(`Shape Details Before Rotation:`);
        console.log(`ID: ${shape.id}`);
        console.log(`Name: ${shape.name}`);
        console.log(`Type: ${shape.type}`);
        console.log(`Width: ${shape.width}`);
        console.log(`Height: ${shape.height}`);
        console.log(`Left: ${shape.left}`);
        console.log(`Top: ${shape.top}`);
        console.log(`Rotation: ${shape.rotation}`);

        // Attempting to rotate
        shape.rotation = shape.rotation + 180;

        console.log(`Shape Details After Rotation:`);
        console.log(`ID: ${shape.id}`);
        console.log(`Name: ${shape.name}`);
        console.log(`Type: ${shape.type}`);
        console.log(`Width: ${shape.width}`);
        console.log(`Height: ${shape.height}`);
        console.log(`Left: ${shape.left}`);
        console.log(`Top: ${shape.top}`);
        console.log(`Rotation: ${shape.rotation}`);
    });

    await context.sync();
});

Issues:

  • The shape.flip("Horizontal") method does not seem to apply to grouped shapes.
  • The shape.rotation property is returning undefined or NaN.

Environment:

  • PowerPoint Add-in using Office.js
  • Office.js API Version: [insert version]

Questions:

  1. How can I correctly flip or rotate grouped shapes in PowerPoint using Office.js?
  2. Is there a workaround or alternative approach to achieve this?

Any insights or suggestions would be greatly appreciated!

What I Tried:

  1. Flipping Shapes:

    • I attempted to use the shape.flip("Horizontal") method to flip selected shapes horizontally. This worked for individual shapes, but when applied to grouped shapes, it had no effect.
  2. Rotating Shapes:

    • I tried accessing and setting the shape.rotation property to rotate the shapes by 180 degrees. However, the shape.rotation property returned undefined before rotation and NaN after attempting to set it, indicating that rotation might not be supported or available for grouped shapes.
  3. Logging Shape Properties:

    • I logged various properties of the selected shapes (ID, name, type, width, height, left, top, and rotation) before and after attempting the flip and rotation. This helped me verify that the flip and rotation were not being applied as expected.

What I Was Expecting:

  1. Successful Flip:

    • I expected the shape.flip("Horizontal") method to flip all selected shapes horizontally, including grouped shapes, as it does for individual shapes.
  2. Rotation Support:

    • I expected to access the current rotation value of the shape, modify it, and then apply the new rotation to the shape, including for grouped shapes.
  3. Accurate Property Logging:

    • I expected the rotation property to reflect the correct rotation value before and after applying the transformation, rather than returning undefined or NaN.

My goal was to successfully flip or rotate grouped shapes in PowerPoint using Office.js, but I’m facing challenges in achieving this.

New contributor

Mohammed Alostah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật