that's' more of a question for VB forums. I recall seeing something in one of those about that. Word has some kind of bug that requires something unorthodox to get it to work but I don't recall the details.
Dave --- On Mon, 11/2/09, justusjan <[email protected]> wrote: From: justusjan <[email protected]> Subject: [delphi-en] Office automation - hiding commandbars To: [email protected] Date: Monday, November 2, 2009, 12:30 PM writing an Office viewer (read-only) application, I dynamically create an TOleContainer on a form and use that to open the Excel or Word file. Next, the Toolbars (CommandBars) should be made invisible, what I try to accomplish by using Set_Visible( False). For Excel, this works perfectly with the following code: <code> with TOleContainer. Create(Self) do begin Parent := Self; Left := 0; Top := 0; Align := alClient; AutoActivate := aaManual; AutoVerbMenu := False; OnDeactivate := OleContainerDeactiv ate; CreateObjectFromFil e(sFilename, False); DoVerb(ovPrimary) ; WB := OleObjectInterface as _Workbook; iCommandBars := WB.Application. CommandBars. Count; with WB.Application do for iCommandBar := 1 to iCommandBars do begin if (CommandBars[ iCommandBar] .Type_ = 0) then CommandBars[ iCommandBar] .Set_Visible( False); end; LCID := LOCALE_USER_ DEFAULT; WB.Application. Interactive[ LCID] := False; WB.Application. DisplayFormulaBa r[LCID] := False; UpdateObject; end; </code> However, when I adapt the code to use Word, it seems to ignore the whole Set_Visible thing. The for ... loop IS executed though: <code> with TOleContainer. Create(Self) do begin Parent := Self; Left := 0; Top := 0; Align := alClient; AutoActivate := aaManual; AutoVerbMenu := False; OnDeactivate := OleContainerDeactiv ate; CreateObjectFromFil e(sFilename, False); DoVerb(ovPrimary) ; Doc := OleObjectInterface as _Document; iCommandBars := Doc.Application. CommandBars. Count; with Doc.Application do for iCommandBar := 1 to iCommandBars do begin if (CommandBars[ iCommandBar] .Type_ = 0) then CommandBars[ iCommandBar] .Set_Visible( False); end; UpdateObject; end; </code> I tried replacing the Doc.Application with TWordApplication, like this: <code> WordApplication := TWordApplication. Create(Self) ; WordApplication. ConnectTo( Doc.Application) ; </code> but it didn't change anything. Can anyone help? Thanks, Justus [Non-text portions of this message have been removed]

