Make a WordArt not recieve focus

131 Views Asked by At

Is there an API in VSTO/VBA for Excel or Aspose Cells for Java to make it so that a WordArt I added to the Excel worksheet never receives keyboard or mouse focus?

For e.g. in the picture below, when I click on the WordArt, it receives focus. When it has focus and I hit the Tab key on the keyboard, the focus goes to the next WordArt, i.e. the one above it.

I'd like these WordArt objects never to receive keyboard or mouse focus. Is there a way?

enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

This can be achieved by protecting your worksheet. You can learn from internet how to protect worksheet and its contents or objects. Aspose.Cells supports the protection of worksheet.

Please see the following sample code which uses Aspose.Cells APIs. It explains how to protect your worksheet contents or objects. Please modify the code as per your needs.

Both Java and C# codes are given for a reference.

Java

//Load your workbook
Workbook wb = new Workbook("sample.xlsx");

//Access first worksheet
Worksheet ws = wb.getWorksheets().get(0);

//Unlock all cells of your worksheet
Style st = ws.getCells().get("A1").getStyle();
st.setLocked(false);

StyleFlag flg = new StyleFlag();
flg.setLocked(true);

ws.getCells().applyStyle(st, flg);

//Specify protection types
Protection p = ws.getProtection();
p.setAllowEditingContent(false);
p.setAllowEditingObject(false);
p.setAllowEditingScenario(false);

//Protect the worksheet
ws.protect(ProtectionType.ALL);

//Save the workbook
wb.save("output.xlsx");

C#

//Load your workbook
Workbook wb = new Workbook("sample.xlsx");

//Access first worksheet
Worksheet ws = wb.Worksheets[0];

//Unlock all cells of your worksheet
Style st = ws.Cells["A1"].GetStyle();
st.IsLocked = false;

StyleFlag flg = new StyleFlag();
flg.Locked = true;

ws.Cells.ApplyStyle(st, flg);

//Specify protection types
Protection p = ws.Protection;
p.AllowEditingContent = false;
p.AllowEditingObject = false;
p.AllowEditingScenario = false;

//Protect the worksheet
ws.Protect(ProtectionType.All);

//Save the workbook
wb.Save("output.xlsx");

Note: I am working as Developer Evangelist at Aspose

1
On

Well, in Aspose.Cells APIs, you may try using certain locking attributes of the wordart shape to accomplish your task, see the sample code for your reference: e.g Sample code:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
Shape wordart = worksheet.getShapes().addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_1, "CONFIDENTIAL", "Open Sans", 50, false, true, 18, 8, 1, 1, 130, 800);

    //Lock Shape Aspects.
    wordart.setLocked(true);
    wordart.setLockedProperty(ShapeLockType.SELECTION, true);
    wordart.setLockedProperty(ShapeLockType.SHAPE_TYPE, true);
    wordart.setLockedProperty(ShapeLockType.MOVE, true);
    wordart.setLockedProperty(ShapeLockType.RESIZE, true);
    wordart.setLockedProperty(ShapeLockType.TEXT, true);

    FillFormat wordArtFormat = wordart.getFill();
    wordArtFormat.setFillType(FillType.SOLID);
    wordArtFormat.getSolidFill().setColor(Color.getLightGray());
    wordArtFormat.setTransparency(0.55);
    wordart.setHasLine(false); 

    workbook.save("out1.xlsx");

Hope, this helps a bit.

I am working as Support developer/Evangelist at Aspose.