Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Dear all,
I wish I could interact with text region of a mathcad document using a VBA form.
Does anyone know a way to access to text region object (I'm talking about sentences, not string assigned) ?
Thanks by Advance.
François
Have a look at the Extra Components worksheet which Richard has posted. There will be something in there which will work.
http://communities.ptc.com/docs/DOC-1071#comment-3162
Mike
Thank you Mike for you answer. I watched at Richard's file carrefully and didn't find yet what I'm looking for.
I realize my description maybe needs an example :
I open mathcad (15.0 in my case) and directly write the sentence on my worksheet : "A man on a tree".
So I wonder : Does Mathcad automation allow me to write this sentence in my worksheet using VBA script? And does it allow me to read this sentence?
I aim to developp a script which identify titles level using tags (T1, T2, T3 ...) And includes numbering in titles text region .
This is a very tricky point.
I have tried to write a table of contents before and found it was too much hassle. Unfortunately Mathcad hasn't really got the features to do this.
You can only access the XML of a math region via the automation interface, not a tex region. The only way I can think of modifying the text would be to edit the file itself.
Hello François,
I've attached files to show the progress that I've managed so far in this direction.
The table of contents was a direct copy from this forum.
The xl sheet can re-write a given region of XML code but it is difficult to manage.
If you have a template with a tagged region it is possible to change just about anything , BUT it is also possible to corrupt everything so caution is advised.
The worksheet will allow the selection of any mathcad file , the current macro is specific to the A.XMCD file attached and will save a changed worksheet under a new name
The Label position file was an attempt to modify items from within mathcad , there are many fields in the XML structure (look in the help> Developer reference under the automation interface).
I didn't find enough information to make it very useful but still a good start point.
The program can read the XY coordinates for any region & the hope was that these could be modified.
So far they appear to be read only.
This is totally dependant on the interface that PTC allow.
It can read the XML code for math regions & this (in theory) should have read write permission.
So far. however I haven't managed to access any text content.
Hope this is of some use to you, If you find any improvements please post them as I will be interested to find new way to control the way that mathcad works
Regards
Andy
Thanks Andy,
This helped me a lot! Including creating a matrix in XML (I had to search a bit about XML table formats but i got there). However my Mathcad file has an embedded excel spreadsheet instead of a matrix...Do you know about OLE2 Mathcad interface? I would prefer to activate the embedded excel spreadsheet (like we do by double-clicking) and then copy paste my new valuesthrough VBA (i.e. The VBA code, like yours will be on an independent workbook). I also found a post about the excel add-in mathcad but I couldn't install this so I don't know what can I get from there)
Thanks a lot,
Marisa Soares
Your post here makes it no clearer what you want to do than your PM. Do you want to call Mathcad from Excel, or call Excel from Mathcad?
Dear all,
Thank you for your help.
So there is no way to interact with text region using Mathcad automation.
I will look for another way to make this table of contents.
Andy,
Thank you for your explaination.
I inserted an Excel file in my calculation note. So I manage to create a numbering with Excel formula considering tabulation (for each tabulation, it takes into account a sub-level).
So this file provide an output table with all my numbered titles.
Then I call this table in another Excel component for each title in my note.
This is not really accurate and considering nearly 140 titles my mathcad file weight is about 7 Mo and needs a few minutes to be opened...
Table of contents is a real missing utils in Mathcad.
Regards
Table of contents is a real missing utils in Mathcad.
It certainly is and one which I hope will be included in Prime in future releases.