NetOfficeFw / NetOffice

🌌 Create add-ins and automation code for Microsoft Office applications.
MIT License
697 stars 143 forks source link

what is this error netoffice error #303

Closed jinsw1081 closed 3 years ago

jinsw1081 commented 3 years ago

NetOffice.NetOfficeException: 'Factory is not initialized with NetOffice assemblies.'

i make ppt to png , jpg converter

this code worked in microsoft.interop.powerpoint win10, WPF , c# , .net framework 4.5 ,nuget is 4.5 powerpoint and netoffice core this my code

`using NetOffice.OfficeApi.Enums; using NetOffice.PowerPointApi; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;

namespace PPTConverter2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

    private void button1_Click(object sender, EventArgs e)
    {
        OpenFileDialog dlgOpenFile = new OpenFileDialog();

        dlgOpenFile.Filter = "Image Files (*.ppt, *.pptx) | *.ppt; *.pptx; | All files (*.*) | *.*";

        if (dlgOpenFile.ShowDialog().ToString() == "OK")
        {
            textBox1.Text = dlgOpenFile.FileName;
        }

    }

    private void button2_Click(object sender, EventArgs e)
    {
        OpenFileDialog open = new OpenFileDialog();
        FileInfo File_Check = new FileInfo(textBox1.Text);

        if (File_Check.Exists)
        {
            NetOffice.PowerPointApi.Application app =
             new NetOffice.PowerPointApi.Application();

            Presentation ppt = app.Presentations.Open(textBox1.Text
                , MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);

            string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            for (int i = 0; i < ppt.Slides.Count; ++i)
            {
                //error is occured here 
                ppt.Slides[i + 1].Export(docPath + "/" + i + ".png", "PNG",
                    (int)ppt.Slides[i + 1].Master.Width,
                    (int)ppt.Slides[i + 1].Master.Height);

            }
            ppt.Close();
            app.Quit();
            MessageBox.Show("Sucees");

        }

        else
        {
            MessageBox.Show("wrong path");
            return;
        }`
jinsw1081 commented 3 years ago

https://github.com/NetOfficeFw/NetOffice/issues/276

jozefizso commented 3 years ago

Yes, this looks like issue with incorrect NetOffice libraries as described in #276

jinsw1081 commented 3 years ago

@jozefizso netoffice need office program ???

jozefizso commented 3 years ago

Yes, it does.

jozefizso commented 3 years ago

Closing the issue as it seams it was resolved.