相棒(chatGPT)と共同作業でプログラミングスキルアップ!(その1、パワポルビ付けアプリ作成)-04 共同作業#プロンプト①
ここから始まりました。(PowerpointもC#も熟知しているわけではないYouです)
You) PowerPointにルビを付ける機能は、ありますか?
ChatGPT) 残念ながら、私の知識が2022年1月までのものであるため、PowerPointにおいて直接ルビを振る機能が存在するかどうかについては確認できません。
You) PowerPointにルビを付ける機能をc#などで追加出来ませんか?
ChatGPT) PowerPointにC#などでルビを付ける機能を追加することは理論的には可能ですが、そのためにはMicrosoft PowerPointのオートメーションやOpen XML SDKを使用する必要があります。以下は、C#を使用してPowerPointにルビを追加する簡単な例です。
csharp Copycode
using Microsoft.Office.Interop.PowerPoint;
class Program
{
static void Main()
{
Application pptApp = new Application();
Presentation presentation = pptApp.Presentations.Add();
Application pptApp = new Application();
Presentation presentation = pptApp.Presentations.Add(MsoTriState.msoTrue);
// スライドを作成
Slide slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutText);
// テキストを追加
TextRange textRange = slide.Shapes[1].TextFrame.TextRange;
textRange.Text = "漢字";
// ルビを追加
textRange.Characters(1, 1).Font.Superscript = MsoTriState.msoTrue;
textRange.Characters(2, 1).Font.Superscript = MsoTriState.msoFalse;
pptApp.Visible = MsoTriState.msoTrue;
}
}You ) pptApp.Presentations.Add();がエラーになります。
ChatGPT)
using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core; <===追加
詳細は略
内容は7行目を変えてきました
Presentation presentation = pptApp.Presentations.Add();
を
Presentation presentation = pptApp.Presentations.Add(MsoTriState.msoTrue);
に変更You) using Microsoft.Office.Core; がエラーです
ChatGPT)
というような会話を数十回と繰り返しながら少しずつ完成に近づいていきます。
