Tag: ole

Vba:通过Excel.Application在Word中编辑图表

我有一个简单的问题:我想编辑一个Word文档中的所有图表。 更确切地说,我想在所有图表中执行search和replace(他们的数据更加精确)。 现在我的做法是做这样的事情: Dim appExcel as Excel.Application Dim wb as Excel.Workbook Dim ws as Excel.Worksheet Dim shp as InlineShape Dim cht as Word.Chart For each shp in ActiveDocument.InlineShapes If shp.HasChart then set cht = shp.Chart 'Here comes the Question: how to assign the chartdata.workbook to wb? end if next shp 有人有想法吗? 我会很感激! 谢谢 :)

自动化对象不支持Excel自动化“FitToPagesWide”

我试图将Excel工作表导出为PDF,我希望工作表适合页面的宽度。 在做一些研究,似乎我应该使用FitToPagesWide,但是,我无法finddelphi的例子..这是我的代码: procedure TForm1.ExcelToPDF(const AFilename: string); Const XlTypePDF = 0; xlQualityStandard = 0; IncludeDocProperties = true; IgnorePrintAreas = false; LandscapeMode = 2; var P: OleVariant; begin P:= CreateOleObject('Excel.Application'); try P.WorkBooks.Open(AFilename, 3); p.ActiveSheet.Pagesetup.Orientation := LandscapeMode; orientation p.ActiveSheet.PageSetup.FitToPagesWide := 1; // <– not supported by automation object p.ActiveWorkbook.exportAsFixedFormat(xlTypePDF, AFilename, xlQualityStandard, IncludeDocProperties, IgnorePrintAreas ); finally p.Quit; end;

如何在Excel中使用Perl和OLE打开制表符分隔的文本文件?

本来我试图用Excel打开一个XML文件。 但是,由于这需要很长时间,我自己将XMLparsing为制表符分隔的文本文件。 我以为我在互联网上find了正确的语法。 我使用我用Excelmacroslogging的值来尝试下面的代码。 我有一个18列制表符分隔的文件。 调用“工作表”方法时,下面代码的最后一行出现错误。 错误消息: 不能调用方法“Worksheets”没有包或对象引用在./PostProcessingDev.pl行70。 use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; Win32::OLE->Option(Warn => 3); use strict; my $Excel; my $Sheet; my $Workbook; $Excel = CreateObject OLE "Excel.Application"; $Workbook = $Excel->Workbooks->OpenText({Filename =>"$inSelf->{'TXT'}", Origin => xlMSDOS, StartRow => 1, DataType => xlDelimited, TextQualifier => xlDoubleQuote, ConsecutiveDelimiter => "False", Tab => "True", Semicolon => "False", […]

使用Perl Win32 :: OLE从Excel工作表中获取超链接列表

我想更改Excel电子表格中一堆超链接的path。 在searchGoogle之后,我遇到了将超链接添加到电子表格的问题的解决scheme ,但没有改变它们。 微软在这里展示了如何与VBA接近。 由于我想编辑文档中的每个超链接,所以我不知道如何解决的关键步骤是: 获取Perl中超链接对象的列表 提取他们的地址1和1 运行正则expression式来改变path 将更新的path存储在超链接 – >对象中并重复 我是使用OLE的新手,正在被绊倒(1)。 这是我迄今为止所尝试的: #!perl use strict; use warnings; use 5.014; use OLE; use Win32::OLE::Const "Microsoft Excel"; my $file_name = 'C:\path\to\spreadsheet.xlsx'; my $excel = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}); $excel->{Visible} = 1; my $workbook = $excel->Workbooks->Open($file_name); my $sheet = $workbook->Worksheets('Sheet 1'); foreach my $link (in $sheet->Hyperlinks ) { […]

如何在c ++中读取/写入excelcheckbox状态

我正在处理一个问题,需要我读取/写入Excel中给定单元格中checkbox的状态。 我知道你可以访问使用COM / OLE访问的ActiveX控件。 但是,我一直没能find解决这个问题的办法。 事实上,我甚至不确定是否可以使用行列访问checkbox。 我研究了activeXcheckbox的属性。 find顶部和左侧的属性,但不是行列 我想问一下:1.有没有直接的方法可以做到这一点。 2.如果不是这样,任何间接的方式,比如说得到顶部/左边的列,然后得到行/列的位置,并比较两者。 3.有什么办法可以用表单控件做同样的事情吗?

使用Perl Excel OLE同时将数据写入不同的Excel文件时出现数据不一致问题

使用下面的Perl脚本,我试图同时打开和写入不同的Excel表单中的数据。 虽然它有效,但我发现这种方法存在一些数据不一致的问题。 即一些file1数据在file2中被看到,反之亦然。 我对Perl OLE句柄没有清楚的理解。 由于它对于不同的文件使用相同的perl OLE句柄,Perl是否将所有不同的文件视为一个? 如果那么如何避免这种情况呢? perl Parser.pl C:\ report1.xlsx perl Parser.pl C:\ report2.xlsx perl Parser.pl C:\ report3.xlsx Parser.pl use Win32::OLE qw(in with); # OLE Automation extensions use Win32::OLE::Const 'Microsoft Excel'; # Extract constant definitions from TypeLib unless (defined $Excel1) { $Excel1 = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or die "Oops, cannot start Excel"; } […]

delphi:为什么const设置为这个奇怪的值,使用Excel OLE interop?

对不起,我非常无聊,我想知道为什么const lWBATWorkSheet设置在-4167 。 谢谢,杰克 function TForm1.SaveAsExcelFile(AGrid: TStringGrid; ASheetName, AFileName: string): boolean; const xlWBATWorksheet = -4167; var righe, colonne: Integer; GridPrevFile: string; XLApp, Sheet, Data: OLEVariant; l, s: Integer; begin // Prepare Data Data := VarArrayCreate([1, AGrid.RowCount, 1, AGrid.ColCount], varVariant); for l := 0 to AGrid.ColCount – 1 do for s := 0 to AGrid.RowCount – […]

使用excel ole获取错误“Workbooks类的添加方法失败”

我想通过ole打开并刷新一个excel 2003电子表格。 但是我收到错误“添加方法的Workbooks类失败”没有进一步的信息。 该代码工作在unit testing,并在3台服务器上运行,但失败,在我们的networking服务器上的错误。 它是从本地系统帐户下运行的服务应用程序运行的。 所有服务器(2003 sp3)上都安装了相同版本的excel。 有问题的文件都存在,并在预期的位置。 电子表格中没有macros,但有数据库查询。 电子表格都可以打开。 调用代码是 if VarIsEmpty(XLApp) then begin XLApp := CreateOleObject('Excel.Application'); try XLApp.DisplayAlerts:= wdAlertsNone; except … end; XLApp.AutomationSecurity:= msoAutomationSecurityForceDisable; end; fullFileName:= ExpandReportFileName( partialFilename); if not FileExists(fullFileName) then raise Exception.Create('File not found: ' + fullFileName); XLAPP.Workbooks.Add(fullFileName); << fail here 任何想法,我还可以尝试什么?

退出后Excel Ole对象静止进程列表

我有这个代码: function XlsToStringGrid(AGrid: TStringGrid; AXLSFile: string): Boolean; const xlCellTypeLastCell = $0000000B; var XLApp, Sheet: OLEVariant; RangeMatrix: Variant; x, y, k, r: Integer; begin Result:=False; //Cria Excel- OLE Object XLApp:=CreateOleObject('Excel.Application'); try XLApp.Visible:=False; XLApp.Workbooks.Open(AXLSFile); Sheet:=XLApp.Workbooks[ExtractFileName(AXLSFile)].WorkSheets[1]; Sheet.Cells.SpecialCells(xlCellTypeLastCell, EmptyParam).Activate; x:=XLApp.ActiveCell.Row; y:=XLApp.ActiveCell.Column; AGrid.RowCount:=x; AGrid.ColCount:=y; RangeMatrix:=XLApp.Range['A1', XLApp.Cells.Item[X, Y]].Value; k:=1; repeat for r:=1 to y do AGrid.Cells[(r – 1),(k – 1)]:=RangeMatrix[K, R]; […]

ExportAsFixedFormat

为什么下面的代码返回无效的参数错误? 它在Delphi中的等价性执行得很好。 C ++ Builder: ActiveWorkSheet.OleProcedure("ExportAsFixedFormat", 0, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam); delphi: oSheet.ExportAsFixedFormat(0, // xlTypePDF is constant 0 EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, // set to True to open Acrobat EmptyParam);