disable macro when opening word documents using office interop apis - interop

hi
how to disable macros when opening documents using office interop apis. I am currently using office 2007.
thanks in advance

If you're automating using VB.NET, it's quite easy - see this thread for an example of DisableAutoMacros: How to open document that contains AutoOpen macro with PowerShell?. I was never able to figure out how to do this in C# though.

Related

Shape property "decorative" not in VSTO?

I program PowerPoint add-ins both in VBA and in VSTO. In VBA I can use shape.Decorative to check, if a shape is decorative - and therefore does not need an alternative text. In VSTO however there is no such property.
I'm using Visual Studio 2022, the reference to PowerPoint is set to version 15.0.0.0.0 - but I can't see where I could change that. Am I using the wrong template?
I'm grateful for any tips how to get to that attribute. Thanks in advance, Sabina
The PowerPoint object model provides the Shape.Decorative property which sets or returns the decorative flag for the specified object. So, it doesn't matter whether it is a VSTO add-ins or VBA macro. The PowerPoint object model is common for all programming languages. In this situation you can:
Use a newer PIA to get access to the property (with intellisense suggestions).
Use the late-binding technology to invoke the property programmatically even when it is not available in PIAs. The Type.InvokeMember method invokes a specific member of the current Type.

How do you make an add-in for Excel 2011 (Mac)

I would like to add a button to the Ribbon and have it perform some basic tasks when clicked. Is this possible? If so, how?
Thanks in advance.
No, it is not possible. It looks like it is possible, but it is not. The only proper add in for Excel 2011 Mac is provided with Excel, and the ability to show it in Excel Mac's ribbon is apparently hard-coded into the Excel Mac application. None of the XML-based techniques for extending the Excel Mac ribbon work because the ribbon is hard-coded. It looks like the Windows version, but it is nothing like it.
Obviously, it is hard to provide sources for a negative answer. I have researched this topic carefully including contacting Microsoft support, and found that there is no compiler or IDE from Microsoft for this purpose. You can certainly develop in VBA in Excel Mac, and you can make an XLA add-in, but you cannot access the ribbon. You can create little square Mac toolbar icons, just as in Excel 98.
Here are some useful links that will answer your question:
how to customize the ribbon
how to customize the ribbon with vba
how to create an add in (on MSDN)
a clearer tuto on how to create an addin
Please ask a more precise question if you want more precise help.

Is it possible to embed SSRS ReportViewer in VB6 program?

My team is looking for a manner to embed SSRS Report Viewer into a currently working VB6 program as the replacement of Crystal Report. Is it possible? if so, and how?
Many thanks!
Not sure about that, but you can certainly use a different approach such as:
Build a .NET WinForms program (exe) that uses the SSRS Report Viewer control and just call it with a VB6 Shell() + the parameter(s) of the report to run.
Not that I know of however another option would be to use a canned web browser control on a VB6 form and call the report using its URL

Programatically configure Office 2010 Word Ribbon via VBA

Is it possible to configure a Ribbon (e.g. adding a tab etc.) in Office 2010 programatically via VBA? I.e. by writing VBScript code in a macro.
Br. Morten
You can manipulate a Ribbon tab and its controls using VBA, but you cannot create one. Not with the Object Model anyway. The best you could do - somehow - is to get some kind of OPC dll (like an ActiveX component) that handles opening/relationships/closing of OPC documents (like .docx documents) and old school MSXML for creating a ribbon definition and adding it to the package.
Have a look at this blog post for Excel
http://www.xtremevbtalk.com/showthread.php?t=265636
and this one for Word
http://www.wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.htm
If your UI is static, i.e. you don't need to programatically change the behavior of, or add/remove UI elements on the fly, you can define a customUI within a macro-enabled template. You can use your VBA functions as call-backs for the UI elements defined in the XML.
Have a look at this guide. In a nutshell, you define a customUI\customUI14.xml file within the .dotm archive. This XML describes your custom ribbon elements using this schema.
This definitely works for Word templates (.dotm files). I think a similar approach works for any OOXML format.

Can I create a Visual Studio 2010 Add-In that Uses a WPF Display?

We're working on creating a specialized graphical editor for our enterprise applications. We've looked at and rejected DSLs. Ideally I'd like to have the main interface of the editor be docked like the code windows and use WPF for drawing. Can anyone point me to some documentation to get me on the right path?
Thanks.
Colin.
UPDATE: It's beginning to look like "no." From http://msdn.microsoft.com/en-us/library/bb166228.aspx: "Document windows are created by implementing an editor. The IVsEditorFactory interface creates document windows as part of instantiating an editor. For more information, see Accessing the Editor By Using Legacy Interfaces."
Following the link to http://msdn.microsoft.com/en-us/library/dd885127.aspx gives this this bit of advice: "You can access the Visual Studio editor from legacy interfaces. The Visual Studio SDK includes adapters known as shims, which enable these interfaces to interact with the new editor. Nevertheless, we recommend that you update your legacy code to use the new editor API. Your code will perform better and you can use new technologies such as the Windows Presentation Foundation (WPF) and the Managed Extensibility Framework (MEF)."
So, to sum up: if you want to implement an editor you have to use the legacy interfaces, but you shouldn't use the legacy interfaces because then you can't use WPF or MEF.
Seriously Microsoft, WTF?
UPDATE 2: Now that I have the proper names ("custom editor"), I was able to find the following topic: http://social.msdn.microsoft.com/Forums/en-US/vsxprerelease/thread/9e605d0f-1296-47c9-a534-e54905251ebe
I still don't see why they couldn't have included that somewhere prominent in the MSDN docs. You know, like somewhere near where they tell you that you can't use WPF if you're using the legacy interfaces.
Creating a custom editor doesn't have to be terribly painful. Yes, a custom editor will require implementing a few interfaces, but you can still use WPF to actually create the control that is hosted in the VS document frame.
DiveDeeper's blog has some great resources for learning about creating a custom editor.
Creating a simple custom editor - the basics
Creating a simple custom editor - the first 10 meters
Creating a simple custom editor - under pressure
I'd recommend using a library like VSXtra to do a lot of the work for you. It will provide you with a nice base implementation of an editor factory, editor pane, package, etc. Istvan Novak writes about building a custom editor with his VSXtra library in this blog post.

Resources