Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hello,
I was wondering if I could get help with a VBS script to export bolded text with an equal sign from a Mathcad file to a cvs/txt file
An example of text to export is
Val1 = 1 and Val2 =2 would print to the cvs/txt file as
Val1,”1”
Val2,”2”
While the remaining text would be ignored.
Attached is a vbs script that gets all of the text from a Mathcad, but I need to add a conditional that will only print text if it is Bolded and has an equals (=) sign.
I cannot work on this at work since running scripts is blocked and I am working on permission to run this one.
Hi @TD_11399801,
Thank you for your question!
Your post appears well documented but has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.
Also, feel free to add any additional information you think might be relevant.
Best regards,
Hi,
Sorry it has taken so long to respond.
Every region in the worksheet has a property called "Tag". You can set this for individual regions to the same value.
It is possible in vbscript to read the Tag property to see which ones are tagged and respond accordingly.
Right click on a region in Mathcad 15 and select Properties.
You get this dialog box to set the Tag.
' MathcadExtractText.vbs
Set Mathcad = CreateObject("Mathcad.Application")
Set Worksheet = Mathcad.Worksheets.Open("F:\Prime\VB\worksheet.xmcd")
Set TextFile = CreateObject("Scripting.FileSystemObject").CreateTextFile("F:\Prime\VB\output.txt", True)
For Each Region In Worksheet.Regions
If Region.Type = 1 Then ' denotes an expression region in Mathcad
bstr = Region.Tag' Region.XML does not work either.
tokens = Split(bstr, vbCrLf)
For i = 0 To UBound(tokens)
TextFile.WriteLine(tokens(i))
Next
End If
Next
TextFile.Close
Worksheet.Close
Mathcad.Quit
ThisOne
ThisOne