Autor Beitrag
rd3
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 05.12.08 11:29 
Hi, ich hab mal eine Frage und hoffe, Ihr könnt mir helfen... Ich möchte gerne alle eingebetteten Dateien aus einem Word-Dokument speichern, nur weiß ich nicht genau, wie das geht... Es ist aber denke ich auf diese Art - also über InlineShapes - zu lösen... Folgenden Code habe ich unter MSDN gefunden und es wäre schön, falls dieser Code das macht, mir evtl einer das in Delphi umsetzen könnte.

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
Code Snippet

         object VerbIndex = 1;

            object missing = Type.Missing;

            Word.Document doc = app.ActiveDocument as Word.Document;

            foreach (Word.InlineShape inlineShape in doc.InlineShapes)

            {

               

                if(inlineShape.OLEFormat.ProgID != null)

                {

                    switch (inlineShape.OLEFormat.ProgID)

                    {

                        case "PowerPoint.Show.12":

                            inlineShape.OLEFormat.DoVerb(ref VerbIndex);

                            PowerPoint.Application ppt = Marshal.GetActiveObject("PowerPoint.Application"as PowerPoint.Application;

                            ppt.ActivePresentation.SaveAs(@"C:\testPPT.pptx", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsPresentation, Microsoft.Office.Core.MsoTriState.msoTrue);

                            ppt.Quit();

                            break;

 

                        case "Excel.Sheet.12":

                            inlineShape.OLEFormat.DoVerb(ref VerbIndex);

                            Excel.Application excel = Marshal.GetActiveObject("Excel.Application"as Excel.Application;

                            excel.ActiveWorkbook.SaveAs(@"C:\testBOOK.xlsx", missing, missing, missing, missing, missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, missing,

                                missing, missing, missing, missing);

                            excel.Workbooks.Close();

                            excel.Quit();

                            break;

 

                        case "Word.Document.12":

                            Word.Document document = inlineShape.OLEFormat.Object as Word.Document;

                            object fileName = @"C:\testDOC.docx";

                            document.SaveAs(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing,

                                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,

                                ref missing, ref missing, ref missing);

                            break;

 

                        default:

                            break;

                    }

                }

            }


Vielleicht hat ja jemand einen Ansatz oder kann mir helfen...
Vielen Dank vorab... Gruss rd3
rd3
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 08.12.08 10:55 
hat keiner eine Idee?!
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 08.12.08 15:29 
COM sollte fast 1:1 in Delphi übernehmbar sein

_________________
Markus Kinzler.
rd3
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 08.12.08 17:31 
könntest du mir für z.B. ein dokument ein beispiel machen? das wäre nett... :)
rd3
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 09.12.08 11:30 
könnte mir das o.g. beispiel jemand bitte in delphi umsetzen?
rd3
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 10.12.08 19:15 
hat sich erledigt... über TypeLibraries (TLB) gelöst...