Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-19-2016, 07:10 AM
jpl jpl is offline VBA and Omath object Windows 7 64bit VBA and Omath object Office 2010 32bit
Advanced Beginner
VBA and Omath object
 
Join Date: Jan 2016
Location: France
Posts: 33
jpl is on a distinguished road
Default VBA and Omath object

Bonjour à vous.
I try to write equations by means of macro.
To insert structures into my equations, I use the OMathFunctions. Add method.
My macros work most of the time, except when I use the OmathFunctionText function with the constant wdOMathFunctionText.



Macro QuiMarche makes for what I expect from it:
Code:
Sub QuiMarche()
      Dim monEq As OMath, maFonction As OMathFunction, maPlage As Range
      ActiveDocument.Range.Delete
      Set monEq = ActiveDocument.OMaths.Add(Selection.Range).OMaths(1)
      
      'on insère le radical
      Set maPlage = monEq.Range
      Set maFonction = monEq.Functions.Add(Range:=maPlage, Type:=wdOMathFunctionRad)
      maFonction.Rad.Deg.Range.Text = "3": maFonction.Rad.e.Range.Text = "8"
      
      'on insère la suite
      Set maPlage = maFonction.Range
      maPlage.Collapse direction:=wdCollapseEnd
      maPlage.Text = " est égal à 2."
      Set maFonction = monEq.Functions.Add(Range:=maPlage, Type:=wdOMathFunctionNormalText)
  End Sub
If I modify the last line, the macro emits an error message which I do not understand:

Erreur d'exécution '6219' : Impossible d'appliquer la fonction texte à une sélection.

Code:
Sub QuiNeMarchePas()
      Dim monEq As OMath, maFonction As OMathFunction, maPlage As Range
      ActiveDocument.Range.Delete
      Set monEq = ActiveDocument.OMaths.Add(Selection.Range).OMaths(1)
      
      'on insère le radical
      Set maPlage = monEq.Range
      Set maFonction = monEq.Functions.Add(Range:=maPlage, Type:=wdOMathFunctionRad)
      maFonction.Rad.Deg.Range.Text = "3": maFonction.Rad.e.Range.Text = "8"
      
      'on insère la suite
      Set maPlage = maFonction.Range
      maPlage.Collapse direction:=wdCollapseEnd
      maPlage.Text = "=2"
      Set maFonction = monEq.Functions.Add(Range:=maPlage, Type:=wdOMathFunctionText)
  End Sub
If I neutralize the last line, the macro works.

I have never managed to use the OmathFunctionText function without that error message. In what circumstances is it possible to use this function, and what is its utility?

In French
Je cherche à écrire des équations à l'aide de macros.
Pour insérer des structures dans mes équations, j'utilise la méthode OMathFunctions.Add.
Mes macros fonctionnent la plupart du temps, sauf quand j'utilise la fonction OmathFunctionText avec la constante wdOMathFunctionText.
La macro QuiMarche fait ce que j'en attends :

Si je modifie la dernière ligne, la macro émet un message d'erreur que je ne comprends pas :
Erreur d'exécution '6219' : Impossible d'appliquer la fonction texte à une sélection.
....
Si je neutralise la dernière ligne, la macro fonctionne.

Je n'ai jamais réussi à utiliser la fonction OmathFunctionText sans le même message d'erreur. Dans quelles circonstances est il possible d'utiliser cette fonction, et quelle est son utilité ?
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Variables in Equation using OMath object pooley343 Word VBA 0 01-09-2015 10:26 AM
VBA and Omath object Click an object on a slide, show another object on the same slide. meppley7 PowerPoint 2 04-28-2014 01:44 PM
tool tip for object slain Outlook 0 05-19-2011 06:06 AM
Problem: object library invalid or contains references to object definitions aligahk06 Office 0 08-19-2010 12:29 PM
Could not load this object as this object is not present in your computer k.gaurav Office 0 08-17-2009 09:57 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:03 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft