In Excel 2010 the equation editor is not listed in the Object Browser. In Word, the object is called OMath http://msdn.microsoft.com/en-us/library/bb256563%28office.12%29.aspx. Maybe Excel uses a Word object to display equations?
So the questions are:
Is there any way to access that object in Excel if said object is not in the object browser?
Specifically about the equation editor, is there any way to access it from vba in excel?
Thanks!
In Excel 2007, when you want to insert an equation, you have to insert an Object > Microsoft Excel Equation Editor 3.0. See on MSDN on how to use this.
You can add a new Equation with:
ActiveSheet.OLEObjects.Add(ClassType:="Equation.3", Link:=False, DisplayAsIcon:=False)
You can access these objects within the OLEObjects collection:
ActiveSheet.OLEObjects.Item(1)
It seems like Microsoft doesn't handle equations in the same way between Excel and Word (2007 at least) because Excel doesn't use the OMath object.
Related
I've written a macro in PowerPoint that, as part of its process, will convert a linked chart in a PowerPoint presentation to an embedded chart by copying the source Excel chart and pasting that copied chart in as an OLE object -- the specific command is, "sldComponent.Shapes.PasteSpecial(ppPasteOLEObject)".
Until today, this has worked fine in all versions from 2003 to 2010. However, when trying to run this function in 2013/365, I keep getting a run-time error stating "The specified data type is not available" (-2147188160 / 80048240). I also notice that in the Microsoft Developers Reference webpage, "ppPasteOLEObject" is no longer listed as an acceptable datatype for the PasteSpecial method (when used with the Shapes collection).
I have found several ways to programmatically paste the chart as a picture, but whenever I click on the pasted chart and try to access the data, I keep getting the message "The linked file is not available." I want the data to be entirely self-contained so the PowerPoint user can edit it without reference to the original Excel file. Interestingly, when I stop the PowerPoint macro at the buggy line and then manually click "Paste" on the ribbon, the copied chart does paste, fully embedded with data accessible, into the active slide -- so the chart is getting copied into the Clipboard; the PowerPoint macro is simply unable to read and paste it for some reason. Even more interestingly (read: frustratingly), the PasteSpecial(ppPasteOLEObject) command will work for tables copied from Excel, i.e. cell ranges, but not for charts.
What happened? How does one use VBA code in PowerPoint 2013 to embed (i.e. insert a previously-created, self-contained Excel chart including all data right in the presentation slide) an Excel chart in the new version?
ADD: I should also note that the command used to get the chart from the source worksheet in Excel is "xlCopySheet.ChartObjects(1).Select", then "appExcel.Selection.Copy". Is the problem that the chosen Copy syntax is not capturing the entire chart including data but only the display? What is the correct Copy syntax to use here?
ADD 2: Further specification: The original macro was saved and was running with both Excel and PowerPoint in Compatibility (97-2003) mode, although the apps themselves are the 2013/Office 365 versions.
If you paste the chart as a "Microsoft Office Graphic Object", the chart is pasted as an Excel chart. You can format it within PowerPoint using the Excel ribbon's Chart Tools tab, which appear in PowerPoint. If you click any of the edit/select data buttons, it opens the data in Excel.
If you paste the chart as a Microsoft Excel Chart Object, it is pasted as an embedded workbook (the entire workbook, not just the chart and its data), with a new chart sheet inserted in the embedded workbook, and this chart sheet is what is visible. You need to double click to format or edit the chart, which opens the embedded workbook in Excel, and may mess up the size of the embedded object (so it's chart-sheet sized, not chart-embedded-in-the-worksheet sized) and things like font size.
If I copy the chart in Excel and use this in the PowerPoint VB Immediate Window
activepresentation.Slides(3).Shapes.PasteSpecial ppPasteOLEObject
I get the second behavior.
You might want to try copying the chart using this:
xlCopySheet.ChartObjects(1).Chart.Copy
I need to get Macros text from the Visio document using VBA. Is there any collection, property etc to access to the macros of the Visio document?
You can access the code in the VBA project for a document, assuming it's unlocked for viewing and the Visio installation security settings allows programmatic access to the VBA project.
If you have a document variable called Doc, it would be Doc.VBProject
If you enable the Microsoft Visual Basic for Applications Extensibility library in the references, you can dim a variable as VBProject and get intellisense to help you figure out how to get what you need.
There seem to be a bunch of things in the Word 2007/2010 VBA object model which are simply missing in Word 2011 VBA.
Specifically, Word 2007 (for Windows) includes objects and methods related to:
ContentControls
CustomXMLParts
OpenXML
For example:
**Word.Document**
Property ContentControls As ContentControls
contentcontrol events eg Event ContentControlAfterAdd(NewContentControl As ContentControl, InUndoRedo As Boolean)
Property CustomXMLParts As CustomXMLParts
Property WordOpenXML As String
**Word.ContentControl**
Property XMLMapping As XMLMapping
**Word.ContentControls**
Function Add([Type As WdContentControlType = wdContentControlRichText], [Range]) As ContentControl
**Word.Selection/Word.Range**
Sub InsertXML(XML As String, [Transform])
In the VBA editor in Word 2011, I can't find any of these.
Are the differences between Word 2011 VBA and Word 2010 VBA object models documented anywhere?
I've also browsed/searched the Script Editor's dictionary, to see whether any of these objects are exposed there. They aren't.
In my experiments so far, Word 2011 does preserve existing content controls in a docx (ie it saves them), but you can't see them on the document surface in the UI, and there doesn't seem to be any way to add new ones (either via the Developer tab, or via VBA or AppleScript).
So, any suggestions as to how to work with around gaps in the Word for Mac 2011 VBA object model generally, and in particular how to work with content controls and custom xml in Word on the Mac?
Unfortunately it appears that CC work in VBA has been removed from Mac Word 2011 VBA. See this page:
Object Model Changes from Microsoft Word 2010
The full online help for Mac Word 2011 VBA is at: http://mac2.microsoft.com/vb/1033/default.aspx?src=wd
Folks,
I would like to write a VBA macro to modify the charts in a Word document but I don't know how ? I used the old school trick below with no hope:
Select a Chart in an open document
Start Macro Recording
Modify the chart
Stop Recording
Edit the macro
The surprise here is that the macro is empty !!
Any advice ?
You may find some useful information in this related question: VBScript and multilevel OLE?
I know PowerPoint supports macros
But is there a way I can insert data from a datasource into a placeholder or something?
I've got a routine where I collect data from a database and store it in the registry. This data is then inserted into several Word templates. And this is working.
But I can't find any bookmark support in PowerPoint and that's kinda how I insert data in Word templates. Can I select a certain placeholder or something in PowerPoint 2007 using macros?
Guess I'll just answer this question myself :)
You can actually do this very easily in PowerPoint 2007 by using the CustomUIEditor.
Just open the template and insert this piece of code
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="onLoadCode" >
</customUI>