View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0037355 | FPC | Compiler | public | 2020-07-15 05:41 | 2020-10-16 05:06 |
Reporter | Sergey Tsukanov | Assigned To | Sven Barth | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 3.2.0 | ||||
Fixed in Version | 3.3.1 | ||||
Summary | 0037355: OLE automation object methods call using named parameters not work in FPC 3.2.0 | ||||
Description | ... w := CreateOleObject('Word.Application'); ... w.Documents.Add(NewTemplate:=true); // this works only in FPC 3.0.4(Lazarus 2.0.8), in FPC 3.2.0 (Lazarus 2.0.10) get error "Method 'Add' is not supported by automation object" | ||||
Steps To Reproduce | Create new application in Lazarus 2.0.10 and place button in form... or use attached file Button OnClick handler: procedure TForm1.Button1Click(Sender: TObject); var w:variant; begin w := CreateOleObject('Word.Application'); w.Visible := true; { https://docs.microsoft.com/ru-ru/office/vba/api/word.documents.add Word.Documents.Add (Template, NewTemplate, DocumentType, Visible) } //w.Documents.Add(,true); //no errors, this works in FPC 3.0.4(Lazarus 2.0.8) and FPC 3.2.0 (Lazarus 2.0.10) w.Documents.Add(NewTemplate:=true); // this works only in FPC 3.0.4(Lazarus 2.0.8), in FPC 3.2.0 (Lazarus 2.0.10) get error "Method 'Add' is not supported by automation object" w := UnAssigned; end; | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 45974 | ||||
FPCOldBugId | |||||
FPCTarget | - | ||||
Attached Files |
|
|
|
|
I can not reproduce with Lazarus 2.0.10 and FPC 3.2.0 on i386-win32 and x86_64-win64. Also please provide an example that does not depend on Lazarus. |
|
.pas and .exe file compiled in FPC 3.2.0 attached. compile in FPC 3.0.4 and run, no errors, MSWord started and open new template... c:\Tmp\OLENamedParams>c:\Lazarus208\fpc\3.0.4\bin\i386-win32\fpc.exe c:\Tmp\OLENamedParams\onp_err.pas Free Pascal Compiler version 3.0.4 [2020/04/11] for i386 Copyright (c) 1993-2017 by Florian Klaempfl and others Target OS: Win32 for i386 Compiling c:\Tmp\OLENamedParams\onp_err.pas Linking c:\Tmp\OLENamedParams\onp_err.exe 21 lines compiled, 3.2 sec, 208784 bytes code, 8756 bytes data c:\Tmp\OLENamedParams>onp_err.exe Press Enter to start MS Word... no error Press Enter to exit... compile in FPC 3.2.0 and run, error: "Method 'Add' is not supported by automation object", MSWord is running but does not open a new template ... c:\Tmp\OLENamedParams>C:\Lazarus2010\fpc\3.2.0\bin\i386-win32\fpc.exe c:\Tmp\OLENamedParams\onp_err.pas Free Pascal Compiler version 3.2.0 [2020/07/07] for i386 Copyright (c) 1993-2020 by Florian Klaempfl and others Target OS: Win32 for i386 Compiling c:\Tmp\OLENamedParams\onp_err.pas Linking c:\Tmp\OLENamedParams\onp_err.exe 21 lines compiled, 2.6 sec, 228032 bytes code, 10228 bytes data c:\Tmp\OLENamedParams>onp_err.exe Press Enter to start MS Word... EEROR:Method 'Add' is not supported by automation object Press Enter to exit... I tried on 2 different PCs, the result is the same. Win10 x64, MS Office 2007. Maybe I'm doing something wrong? |
|
p.s. onp_err.pas: program onp_err; {$MODE OBJFPC} uses SysUtils, ComObj; var w:variant; err:string; begin write('Press Enter to start MS Word...'); readln; try err := ''; w := CreateOleObject('Word.Application'); w.Visible := true; w.Documents.Add(NewTemplate:=true); // this works only in FPC 3.0.4(Lazarus 2.0.8), in FPC 3.2.0 (Lazarus 2.0.10) get error "Method 'Add' is not supported by automation object" w := UnAssigned; except on E:Exception do err := 'EEROR:' + e.Message; end; if err='' then writeln('no error') else writeln(err); write('Press Enter to exit...'); readln; end. |
|
attached .exe compiled in fpc 3.0.4 works without errors |
|
Ah, it's about running the code, not compiling it! Sorry I misunderstood that. Well, then I can't help here, cause I don't have Word to test this... (unassigning myself in the hope that someone else can take it up) |
|
Example for Internet Explorer, the situation is the same, it works without errors when compiling in FPC 3.0.4 and get error(and URL not opened) when compiling in FPC 3.2.0 Please, test it. onp_err.pas: program onp_err; {$MODE OBJFPC} {$macro on} uses SysUtils, ComObj; var w:variant; err:string; begin writeln('FPC ver.: '+ IntToStr(FPC_FULLVERSION)); write('Press Enter to start IE...'); readln; try err := 'no error'; w := CreateOleObject('InternetExplorer.Application'); w.Visible := true; w.Navigate(url:='https://bugs.freepascal.org/view.php?id=37355'); w := UnAssigned; except on E:Exception do err := 'ERROR: ' + e.Message; end; writeln(err); write('Press Enter to exit...'); readln; end. console output: FPC ver.: 30200 Press Enter to start IE... ERROR: Method 'Navigate' is not supported by automation object Press Enter to exit... FPC ver.: 30004 Press Enter to start IE... no error Press Enter to exit... |
|
Okay, with that test I can reproduce it. Thank you! |
|
Parameter "Names" for procedure "SearchIDs" in module "ComObj" is set of strings separated zero symbol. First string contains called procedure name of COM object, next strings contains procedure parameter names. In FPC 3.0.4 after first string one zero symbol. In FPC 3.2.0 - two zero symbols - this leads to incorrect operation, and an error when calling DispatchInterface.GetIDsOfNames.(parameter "NamesArray" is incorrect) One of the possible solutions: In the file "fpc \ 3.2.0 \ source \ packages \ winunits-base \ src \ comobj.pp" replace the string 1430: inc(Names,NameLen+1); to string inc(Names,NameLen+1); if Names^=#0 then inc(Names); |
|
Please test and close if okay. |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-07-15 05:41 | Sergey Tsukanov | New Issue | |
2020-07-15 05:41 | Sergey Tsukanov | File Added: OLE Named Param.zip | |
2020-07-15 15:12 | Sven Barth | Assigned To | => Sven Barth |
2020-07-15 15:12 | Sven Barth | Status | new => feedback |
2020-07-15 15:12 | Sven Barth | FPCTarget | => - |
2020-07-15 15:12 | Sven Barth | Note Added: 0124039 | |
2020-07-15 16:20 | Sergey Tsukanov | Note Added: 0124045 | |
2020-07-15 16:20 | Sergey Tsukanov | File Added: onp_err.zip | |
2020-07-15 16:20 | Sergey Tsukanov | Status | feedback => assigned |
2020-07-15 16:25 | Sergey Tsukanov | Note Added: 0124046 | |
2020-07-15 16:34 | Sergey Tsukanov | Note Added: 0124047 | |
2020-07-15 16:34 | Sergey Tsukanov | File Added: onp_err_fpc304_NO_ERR.zip | |
2020-07-15 16:40 | Sergey Tsukanov | Note Edited: 0124045 | View Revisions |
2020-07-15 22:28 | Sven Barth | Note Added: 0124066 | |
2020-07-15 22:29 | Sven Barth | Assigned To | Sven Barth => |
2020-07-15 22:29 | Sven Barth | Status | assigned => new |
2020-07-16 04:18 | Sergey Tsukanov | Note Added: 0124071 | |
2020-07-16 04:30 | Sergey Tsukanov | Note Edited: 0124071 | View Revisions |
2020-07-16 04:33 | Sergey Tsukanov | Note Edited: 0124071 | View Revisions |
2020-07-16 07:37 | Sven Barth | Note Added: 0124072 | |
2020-07-17 10:51 | Sergey Tsukanov | Note Added: 0124119 | |
2020-07-31 17:43 | Sven Barth | Assigned To | => Sven Barth |
2020-07-31 17:43 | Sven Barth | Status | new => assigned |
2020-07-31 17:56 | Sven Barth | Status | assigned => resolved |
2020-07-31 17:56 | Sven Barth | Resolution | open => fixed |
2020-07-31 17:56 | Sven Barth | Fixed in Version | => 3.3.1 |
2020-07-31 17:56 | Sven Barth | Fixed in Revision | => 45974 |
2020-07-31 17:56 | Sven Barth | Note Added: 0124437 | |
2020-10-16 05:06 | Sergey Tsukanov | Status | resolved => closed |