cancel
Showing results for 
Search instead for 
Did you mean: 

Refresh ole link at runtime ?

Former Member
0 Kudos

Hello,

I have a report in my VS2008 application, in this report i have a linked Word document (aciveX ole object). The word document is modified out of the program. That is working on my computer but at runtime on the customer network when they modify the Word Document, rpt is not updated when they run my application.

How to set/change the link path of the ole object at runtime and refresh report ?

Thanks in advance.

Vincent

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hi Vincent

What version of Crystal reports are you using? Please be precise.

Also, see KBA 1218161 - Linked OLE objects are not updated when previewed in .NET application

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow me on Twitter

Former Member
0 Kudos

Hi ludek,

Thank you for your support, I used the CrystalReport version embedded in VB NET VisualStudio 2008 called : Crystal Reports Basic pour Visual Studio 2008...there is no version number.

Solve this problem is very important for me.

Thanks in advance.

Vincent

0 Kudos

Did you read the KBA Ludek linked to?

Only option is to upgrade to CR 2008 or above. CR Basic for VS did not get this fix.

If you upgrade to VS 2010, 2012, 2013 or 2015 RC you can use the CR runtime from this link:

http://scn.sap.com/docs/DOC-7824

Don

Former Member
0 Kudos

Hi Don,

Sorry i had not seen the link but now i read it. Since VS2010 CR is not joined with VS. If for example i upgrade to VS2010 then i install Support Pack 10 (cr runtime) but  i could not modify anymore my reports in VS and i shall have to possess a standalone version of CR, i am right ?

Thank you for your help.

Viincent

Former Member
0 Kudos

Don,

Once updated VS and CR how to set the link path at runtime to match with the customer configuration ?

Thanks

0 Kudos

SP 14 was just released so use that one,

Yes, once you install that package into VS 2010, 2012, 2013 or 2015RC you can edit your reports. It does not have the full features as the full version of CR Designer. but can do most things.

Don

Former Member
0 Kudos

Ok Don thank you for these informations, but will it be possible to set the link path for the Word document at runtime because paths on my developement computer end paths on customer computer are different?

Regards.

Vincent

Former Member
0 Kudos

Don,

I converted project from VS2008 to VS2010, then i have installed SP 14.

I can open the project with no erros but i don't see any differences with VS2008 version. When i double-clik on my report  now is opened with CR 11.5 standalone cr application which is installed on my computer, in VS 2010 code i tried:

-Dim xx As CrystalDecisions.CrystalReports.Engine.Section = reportDocument1.ReportDefinition.Sections("Section3")

-Dim o As CrystalDecisions.CrystalReports.Engine.PictureObject = x.ReportObjects(0)

-'o.???

but i can't found any link property and any OLE object in crystalReport.engine.

Please tell me how to solve that

Thanks in advance

Vincent

Former Member
0 Kudos

Ludek,

I upgraded with VS2010 and CR runtime SP14 but I do not still know how we set and refresh the link path of the ole object;so please give me an example of VB code to do that.

Thanks

Vincent

former_member183750
Active Contributor
0 Kudos

You should not need any code(?). By definition an OLE object server will automatically take care of the changes to the object.  A test I did:

Create a report with a linked MS Word doc.

Save.

Modify the doc.

Refresh the report - result: OLE Object did not change.

Close and reopen the report - OLE Object change is now visible.

Repeat above in a .NET app - Ole Object changes - if report is closed and reopened in the app.

- Ludek

0 Kudos

In Full CR Designer help file here how to:

To make a static OLE object dynamic

  1. Right-click the static OLE
    object
    that you inserted, and choose Format Graphic from the shortcut menu.

    Note You begin the process
    of making a static OLE object dynamic by inserting the object into your report
    as usual. This object becomes the default object. If Crystal
    Reports cannot find the dynamic reference to the object, it uses the
    default object
    instead.
  2. In the Format
    Editor, click the Picture tab, and then click
    the Conditional Formula button adjacent to the
    Graphic Location label.
  3. In the Formula Workshop,
    create the path to your static OLE object.

    For example, if your path is stored in a database field, add that
    field to the formula.
  4. Click Save and close to return to the Format Editor.
  5. Click OK to return to your report.
  6. Click Refresh to update the reference link to your static OLE
    object
    .

The SDK will only refresh the OLE Object on Open, it will not refresh it when hitting the refresh button in the viewer last I tested.

But I believe if you dynamically link the object using a formula field based on a database field with the path to the ole object it should refresh.

Don

Former Member
0 Kudos

Hi Ludek,

My ole is linked to a Word document  but the document location is different between my computer and that of my customer, when he modify the document how cr can refresh rpt because the link is not the same as mine,i must tell to crystal (at runtime on customer computer) wher the Word document is?!

Am i wrong?

Vincent 

Former Member
0 Kudos

Hi Don,

Thank you very much  for these information i will do some tests.

Regards.

Vincent.

Former Member
0 Kudos

Hi,

I did some test and that doesn't work

When i modify Word document report always displays old data, it works as if data was embedded in rpt, i have verified and it's not the case:

I don't understand why it's is not possible to set link and refresh at runtime, why a such limitation, it is a BASIC property of an OLE object, Access does that since the 80's, for a sofware (version14!) specialized in reporting i don't understand!

Or maybe ommited something.

thanks in advance for help.

Vincent

0 Kudos

I don't exact code but this is something you need to do:

rptClientDoc.ReportDefController.ReportObjectController.Modify( oPlaceholderPicture, oNewPicture );

// this works and does update the report file with the condition formula.

oNewPicture.Format.EnableCanGrow = false;

rptClientDoc.ReportDefController.ReportObjectController.Modify(oPlaceholderPicture, oNewPicture);

And I kind of recall now for some reason I had to call this API 2 times to get it to work...

Don

0 Kudos

See if this sample works for you:

NET-CS2003 RAS-Managed BE115 Add Image | SCN

Basically what you can do is clone the object and make the changes and refresh.

Don

Former Member
0 Kudos

Don,

I'm sorry to disturb you again but i tried your code and it doesn't work for me or maybe i'm missing something :

Then i have downloaded the sample but i think it coded in VS2003, when i launch it VS converter starts but i have errors and code is not converted.

Error is speaking about web site (web application) but i don't understand how this kind of application works.

Vincent

0 Kudos

Remove the CR.Enterprise assemblies. Or just open the vb file in notepad and copy the code needed.

Don

Former Member
0 Kudos

Don, code is in csharp, so there is no vb file, maybe you are speaking about Viewer.aspx.cs, because i can't open the project (conversion error) plus i don't know csharp i have some difficulties to understand the code, i have errors with unknown objects properties when i try in my project. I will try more tomorrow and i'll tell you more.

Vincent

0 Kudos

Open the cs file in notepad and then there are sites available for converting C# to VB.


0 Kudos

Basically you can get the object properties and thne delete the ole object and then add it back in.

That should give you the recent file:

rpt.Load("D:\\CPP Net\\RASXIR2Printer\\oleobject.rpt");
rptClientDoc = rpt.ReportClientDocument;

String MyfilePath = "C:\\temp\\mansheart.jpg";

//Determine which section to add the picture field to - in this case the report footer section
boSection = rptClientDoc.ReportDefController.ReportDefinition.PageFooterArea.Sections[0];

boPictureObject.Left = 1010;
boPictureObject.Width = 500;
boPictureObject.Height = 200;
boPictureObject.Top = 100;
boPictureObject.OriginalWidth = 50;
boPictureObject.OriginalHeight = 30;
boPictureObject.Name = "dontest";

//Add it to the report
boPictureObject = rptClientDoc.ReportDefController.ReportObjectController.ImportPicture(MyfilePath, boSection, 1, 1);

rpt.SaveAs("c:\\temp\\savedimage.rpt", true);
MessageBox.Show("c:\\temp\\savedimage.rpt", "RAS", MessageBoxButtons.OK, MessageBoxIcon.Information);

Former Member
0 Kudos

Hi Don,

Thank you for this code, i'll try it.

Vincent

Former Member
0 Kudos

Hi Don,

Sorry for the delay but i have switched to other way waiting for solution.

How are defined rptclientdoc ?

Thanks.

Vincent

0 Kudos

CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();


CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc;

rptClientDoc = new CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument();

rpt.Load(rptName.ToString(), OpenReportMethod.OpenReportByTempCopy);

rptClientDoc = rpt.ReportClientDocument;

And add all of the RAS assemblies in the References:

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

using CrystalDecisions.ReportAppServer;

using CrystalDecisions.ReportAppServer.ClientDoc;

using CrystalDecisions.ReportAppServer.Controllers;

using CrystalDecisions.ReportAppServer.ReportDefModel;

using CrystalDecisions.ReportAppServer.CommonControls;

using CrystalDecisions.ReportAppServer.CommLayer;

using CrystalDecisions.ReportAppServer.CommonObjectModel;

using CrystalDecisions.ReportAppServer.ObjectFactory;

using CrystalDecisions.ReportAppServer.Prompting;

using CrystalDecisions.ReportAppServer.DataSetConversion;

using CrystalDecisions.ReportAppServer.DataDefModel;

using CrystalDecisions.ReportSource;

using CrystalDecisions.Windows.Forms;

using CrystalDecisions.ReportAppServer.XmlSerialize;

Don

Answers (0)