AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi ExcelApplication: Setzen von DisplayAlerts verursacht Fehler
Thema durchsuchen
Ansicht
Themen-Optionen

ExcelApplication: Setzen von DisplayAlerts verursacht Fehler

Ein Thema von crowley · begonnen am 10. Apr 2007 · letzter Beitrag vom 11. Apr 2007
 
crowley

Registriert seit: 7. Jun 2006
Ort: Emmerich
9 Beiträge
 
#1

ExcelApplication: Setzen von DisplayAlerts verursacht Fehler

  Alt 10. Apr 2007, 18:17
Servus und Hallo,

Ich habe folgendes - nerviges - Problem: Ich möchte eine Excel- Datei mit "meinem" Programm ausdrucken. Allerdings schlägt dies mit der Fehlermeldung "Old format or invalid type library" fehl.

Delphi-Quellcode:
  xlsApp.Connect;
  try
    xlsApp.UserControl := False;
    xlsApp.Visible[GetUserDefaultLCID] := False;
    xlsApp.DisplayAlerts[GetUserDefaultLCID] := False; // Hier Fehler!

    xlsApp.Workbooks.Open(
                          ExpandFileName(loc_FileName), False, False,
                          EmptyParam, '', False, False, EmptyParam,
                          EmptyParam, False, False, EmptyParam,
                          EmptyParam, EmptyParam, False, 0
                         );
    xlsBook.ConnectTo(xlsApp.ActiveWorkBook);
    xlsSheet.ConnectTo(xlsBook.Sheets.Item[1] as _Worksheet);
    xlsSheet.Activate;
    xlsSheet.PageSetup.Zoom := False;
    xlsSheet.PageSetup.Orientation := xlLandscape;
    xlsSheet.PageSetup.FitToPagesWide := 1;
    xlsSheet.PageSetup.FitToPagesTall := False;
    xlsSheet.PrintOut(
                      1, 5000, 1, False,
                      Printer.Printers[Printer.PrinterIndex],
                      False, False, False
                     );
    xlsApp.Workbooks[1].Save(GetUserDefaultLCID);
  finally
    xlsApp.Quit;
    xlsApp.Disconnect;
  end;
Nach etwas Recherche habe ich folgendes dank MSDN gefunden
http://support.microsoft.com/?scid=kb;en-us;320369

Es ist tatsächlich so, dass wir bei uns in der Firma (und bei unseren Kunden) ausschließlich "englische" Windows- Versionen installiert haben, diese aber in Landessprache betreiben. Dadurch kommt es eben zu dieser Fehlermeldung.

Jedenfalls stehen da auch zwei wunderschöne Workarounds, allerdings sind meine VB- Kenntnisse bei +/- 0 und ähm... könnte mir das bitte jemand in Delphi "übersetzen"?

Lösung 1:
Code:
// Execute the Excel method or property using InvokeMember
// so that you can specify the CultureInfo for the call.
// For example, the following code illustrates how you can
// invoke the Workbooks object Add method with "en-US" as
// the CultureInfo:
Dim oApp As New Excel.Application()
oApp.Visible = True
oApp.UserControl = True
Dim oBooks As Object = oApp.Workbooks
Dim ci As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US")
oBooks.GetType().InvokeMember("Add", Reflection.BindingFlags.InvokeMethod, Nothing, oBooks, Nothing, ci)
Lösung 2:
Code:
// Set the CultureInfo prior to calling the Excel method.
// For example:
Dim oApp As New Excel.Application()
oApp.Visible = True
oApp.UserControl = True
Dim oldCI As System.Globalization.CultureInfo = _
    System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentCulture = _
    New System.Globalization.CultureInfo("en-US")
oApp.Workbooks.Add()
System.Threading.Thread.CurrentThread.CurrentCulture = oldCI
Vielen lieben Dank,

Crowley
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:36 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz