Announcement

Collapse
No announcement yet.

Diagramm in Exceltabelle öffnen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Diagramm in Exceltabelle öffnen

    Hallo,

    ich möcht aus einem VB 2005 Programm heraus ein Diagramm mit dem Namen "Diagramm1" in einer Exceldatei öffnen.

    So geht es leider nicht:

    [highlight=vb.net]
    Dim exAPP As Excel.Application
    Dim exWB As Excel.Workbook
    Dim exWS As Excel.Worksheet


    '-----> Excel datei öffnen
    exAPP = New Excel.Application
    exAPP.Visible = True

    '-----> Mappe öffnen
    exWB = exAPP.Workbooks.Open(TextBox1.Text & "makrotest.xls")


    exWS = exWB.Worksheets("Diagramm1")[/highlight]

    Wie mach ich's denn richtig?

    vG

    freyx

  • #2
    Hi,

    das hatten wir vor kurzen schon mal...http://entwickler-forum.de/showthrea...ighlight=excel

    mfG Gü
    "Any fool can write code that a computer can understand. Good programmers write code that humans can understand". - Martin Fowler

    Comment


    • #3
      Ja, Gü, da hast Du Recht.

      ich habe aber trotzdem die Lösung des Problems noch nicht, daher die Frage heute noch mal.

      vG

      fredyx

      Comment


      • #4
        Hi,

        hab nur ein C# Beispiel:
        Code:
        using System.IO;
        using System.Reflection;
        using Microsoft.Office.Interop.Excel;
        
        namespace ConsoleApplication1
        {
        	class Program
        	{
        		static void Main(string[] args)
        		{
        			string fileName = Path.Combine(
        				Path.GetDirectoryName(
        					Assembly.GetExecutingAssembly().Location),
        				"Diagramm.xls");
        
        			Microsoft.Office.Interop.Excel.Application xlApp =
        				new Microsoft.Office.Interop.Excel.Application();
        			xlApp.Visible = true;
        
        			object missing = Missing.Value;
        			Workbook xlWorkBook = xlApp.Workbooks.Open(
        				fileName,
        				missing,
        				missing,
        				missing,
        				missing,
        				missing,
        				missing,
        				missing,
        				missing,
        				missing,
        				missing,
        				missing,
        				missing,
        				missing,
        				missing);
        
        			Chart xlChart = (Chart)xlWorkBook.Charts[1];
        			xlChart.Activate();
        		}
        	}
        }
        mfG Gü
        "Any fool can write code that a computer can understand. Good programmers write code that humans can understand". - Martin Fowler

        Comment


        • #5
          Guten Morgen Gü,

          damit kann ich leider garnichts anfangen!

          vG

          fredyx

          Comment


          • #6
            Der Code ist doch "ident" mit dem von VB.net.

            Chart xlChart = (Chart)xlWorkBook.Charts[1];
            xlChart.Activate();
            mfG Gü
            "Any fool can write code that a computer can understand. Good programmers write code that humans can understand". - Martin Fowler

            Comment


            • #7
              Hallo Gü,

              ich komme nicht klar. Daher siehe eMail an Dich.

              vG

              fredyx

              Comment


              • #8
                Hallo Gü,

                Deine Lösung Klappt natürlich wieder mal.

                Da sie evtl. auch für andere interessant ist, gebe ich sie hier noch mal wieder:

                [highlight=vb.net]
                Dim exAPP As Excel.Application
                Dim exWB As Excel.Workbook
                Dim exWS As Excel.Worksheet

                Dim exWS As Excel.Chart

                '-----> Excel datei öffnen
                exAPP = New Excel.Application
                exAPP.Visible = True

                '-----> Mappe öffnen
                exWB = exAPP.Workbooks.Open(TextBox1.Text & "makrotest.xls")


                '-----> Diagramm öffnen

                exWC = exWB.Charts.Item(1)


                exWC.Activate()
                [/highlight]

                vG

                fredyx

                Comment

                Working...
                X