Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. What do I get back from OLEFormatPtr::GetObject() ?

What do I get back from OLEFormatPtr::GetObject() ?

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomhardwaretutorial
1 Posts 1 Posters 14 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi, The following code snippit, produces an embeded excel object. My question is how do I manipulate it? #import "C:\Program Files\Microsoft Office\Office\EXCEL9.OLB" rename ("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") rename ("DocumentProperties", "DocumentPropertiesXL") no_dual_interfaces//, raw_native_types snip..... WORDLib::_ApplicationPtr pWrd = m_pParentApp; pWrd->Visible = VARIANT_TRUE; WORDLib::_DocumentPtr pDoc = pWrd->ActiveDocument; COleVariant vClassType = "Excel.Sheet"; WORDLib::InlineShapePtr pShp = pDoc->InlineShapes- >AddOLEObject ( vClassType ); WORDLib::OLEFormatPtr pFmt = pShp->OLEFormat; _bstr_t bTyp = pFmt->ClassType; /* ** pFmt->ClassType == "Excel.Sheet.8" ** ** pFmt->Object returns an IDispatch -- but to what ???? */ Excel::_WorksheetPtr pSheetptr = pFmt->GetObject(); // pFmt- >Object; pSheetptr->Range["A1"]->Font->Bold = VARIANT_TRUE; // This fails with Code = 80020003 ( Member not found. ) The functions do exist. If I do this by creating an excel app ptr, then get active worksheet() I can then call these functions to manipluate the work sheet. What I suspect is the GetObject is returning something that can be used to get the app ptr or wrksheet ptr. Regards Ian G /* Object Property Returns the object that represents the specified OLE object's top-level interface. This property allows you to access the properties and methods of the application in which an OLE object was created. Read-only. Remarks Use the TypeName function to determine the type of object this property returns for a specific OLE object. Object Property Example This example displays the type of object contained in shape one on slide one in the active presentation. Shape one must contain an OLE object. MsgBox TypeName(ActivePresentation.Slides(1) _ .Shapes(1).OLEFormat.Object) This example displays the name of the application in which each embedded OLE object on slide one in the active presentation was created. For Each s In ActivePresentation.Slides(1).Shapes If s.Type = msoEmbeddedOLEObject Then MsgBox s.OLEFormat.Object.Application.Name End If Next This example adds text to cell A1 on worksheet one in the Microsoft Excel workbook contained in shape three on slide one in the active presentation. With ActivePresentation.Slides(1).Shapes(3) .OLEFormat.Object.Worksheets(1).Range ("A1").Value = "New text"

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups