パワポに埋め込まれた音声ファイル(.m4a)を別ファイルに保存する
「メディアに名前を付けて保存」という機能が、パワポマクロには無いという。
ChatAIに聞いたら、pptxはzipファイルだから、zipファイルの中を探索して、中の音声ファイルを取り出して保存すればいい、という。
うそーん、と思ったけど、そのプログラム。
OutComp.cs
//c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /target:exe /reference:System.IO.Compression.dll;System.IO.Compression.FileSystem.dll;System.IO.Compression.ZipFile.dll; OutComp.cs
//C:\Windows\Microsoft.NET\Framework\v4.0.30319
//System.IO.Compression.dll
//System.IO.Compression.FileSystem.dll
//System.IO.Compression.ZipFile.dll
using System;
using System.IO;
using System.IO.Compression;
class OutComp
{
static void Main()
{
// zipファイルのパス
string zipPath = @"C:\hogehoge\p1.pptx";
string extractPath = @"C:\hogehoge\out\";
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (Path.GetExtension(entry.FullName).Equals(".m4a", StringComparison.OrdinalIgnoreCase))
{
string destinationPath = Path.Combine(extractPath, entry.Name);
entry.ExtractToFile(destinationPath, true);
}
}
}
}
}