Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-24-2018, 08:01 PM
dogufo dogufo is offline word 2013 operation on text Windows 7 64bit word 2013 operation on text Office 2013
Novice
word 2013 operation on text
 
Join Date: Sep 2018
Posts: 11
dogufo is on a distinguished road
Question word 2013 operation on text

good morning,



I state that my question on word office 2013 is rather pretentious:

it is possible in a word text 2013 to make a macro or a command that identifies a specific number (in my case a 4-digit number), perform an operation on that number ( in my case make a sum) and paste them immediately after a text with the result obtained?


thanks for an answer
Reply With Quote
  #2  
Old 09-24-2018, 08:27 PM
macropod's Avatar
macropod macropod is offline word 2013 operation on text Windows 7 64bit word 2013 operation on text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by dogufo View Post
it is possible in a word text 2013 to make a macro or a command that identifies a specific number (in my case a 4-digit number), perform an operation on that number ( in my case make a sum) and paste them immediately after a text with the result obtained?
Finding a 4-digit number is trivial; you haven't given anywhere near enough detail, though, as to what the parameters for this 'operation' might be. For example, how does one determine whether to add, subtract, divide or multiply (in your case a summation), and what the other value(s) in this operation might be?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-25-2018, 12:09 AM
dogufo dogufo is offline word 2013 operation on text Windows 7 64bit word 2013 operation on text Office 2013
Novice
word 2013 operation on text
 
Join Date: Sep 2018
Posts: 11
dogufo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Finding a 4-digit number is trivial; you haven't given anywhere near enough detail, though, as to what the parameters for this 'operation' might be. For example, how does one determine whether to add, subtract, divide or multiply (in your case a summation), and what the other value(s) in this operation might be?
thanks for your kind reply;

the argument is that I have a long text in word 2013, with several years dates inside (e.g.: 1235 A.D., 1476 A.D., 238 B.C. etc.).

So, I need to find a way to add in the text, concurrently, after these dates another date increased of 2698. E.g.:

1235 A.D., to become in the text after the 'operation': 1235 A.D. (chinese year 3933)

238 B.C., to become in the text after the 'operation': 1235 A.D. (chinese year 2460)



Is that possible to do in word 2013? let me save time and energy

Thanks again for your reply
Reply With Quote
  #4  
Old 09-25-2018, 02:21 AM
macropod's Avatar
macropod macropod is offline word 2013 operation on text Windows 7 64bit word 2013 operation on text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try, for example:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[0-9]{1,4} [AB].[DC]."
    .Replacement.Text = ""
    .Forward = True
    .Format = False
    .Wrap = wdFindStop
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    If Split(.Text, " ")(1) = "B.C." Then
      .InsertAfter " (chinese year " & Split(.Text, " ")(0) + 2699 & ")"
    ElseIf Split(.Text, " ")(1) = "A.D." Then
      .InsertAfter " (chinese year " & Split(.Text, " ")(0) + 2698 & ")"
    End If
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
Note: You'll need to check the correct value to add for B.C. years vs A.D. years, since there was no 0 B.C./A.D.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 09-25-2018, 03:43 AM
dogufo dogufo is offline word 2013 operation on text Windows 7 64bit word 2013 operation on text Office 2013
Novice
word 2013 operation on text
 
Join Date: Sep 2018
Posts: 11
dogufo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Try, for example:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[0-9]{1,4} [AB].[DC]."
    .Replacement.Text = ""
    .Forward = True
    .Format = False
    .Wrap = wdFindStop
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    If Split(.Text, " ")(1) = "B.C." Then
      .InsertAfter " (chinese year " & Split(.Text, " ")(0) + 2699 & ")"
    ElseIf Split(.Text, " ")(1) = "A.D." Then
      .InsertAfter " (chinese year " & Split(.Text, " ")(0) + 2698 & ")"
    End If
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
Note: You'll need to check the correct value to add for B.C. years vs A.D. years, since there was no 0 B.C./A.D.

Thank you very much so this code can be used with python or how to make it work with word 2013? (Sorry, I am not practical )
Reply With Quote
  #6  
Old 09-25-2018, 02:12 PM
macropod's Avatar
macropod macropod is offline word 2013 operation on text Windows 7 64bit word 2013 operation on text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by dogufo View Post
so this code can be used with python or how to make it work with word 2013?
It's a Word macro (which is what you asked for), so it has nothing to do with Python.

For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see: https://wordmvp.com/Mac/InstallMacro.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 09-26-2018, 12:08 AM
dogufo dogufo is offline word 2013 operation on text Windows 7 64bit word 2013 operation on text Office 2013
Novice
word 2013 operation on text
 
Join Date: Sep 2018
Posts: 11
dogufo is on a distinguished road
Thumbs up

thank you very much; it works! even an idiot like me can make it work!

Please, Mr Macropod, because unfortunately I havenīt finished yet if I donīt aks too much... could you please change the code in the way that it makes the same "operation" as described above when there is NOT "A.D." after the 4 digit years numbers So as result I can make 2 macros

tkx very much again from Italy!
Reply With Quote
  #8  
Old 09-26-2018, 06:35 AM
macropod's Avatar
macropod macropod is offline word 2013 operation on text Windows 7 64bit word 2013 operation on text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[0-9]{1,4}>?????"
    .Replacement.Text = ""
    .Forward = True
    .Format = False
    .Wrap = wdFindStop
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    If InStr(.Text, " ") > 0 Then
      Select Case Split(.Text, " ")(1)
        Case "B.C."
          .Text = .Text & " (chinese year " & Split(.Text, " ")(0) + 2699 & ")"
        Case "A.D."
          .Text = .Text & " (chinese year " & Split(.Text, " ")(0) + 2698 & ")"
        Case Else
          .End = .Words.First.End
          .Text = .Text & " (chinese year " & .Text + 2698 & ")"
      End Select
    Else
      .End = .Words.First.End
      .Text = .Text & " (chinese year " & .Text + 2698 & ")"
    End If
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
Do note, however, that the code will now insert the text after any 4-digit number; numbers of other lengths will be ignored.

PS: Please give the magenta a rest...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 04-05-2019, 01:42 AM
dogufo dogufo is offline word 2013 operation on text Windows 7 64bit word 2013 operation on text Office 2013
Novice
word 2013 operation on text
 
Join Date: Sep 2018
Posts: 11
dogufo is on a distinguished road
Default is it possible to do a macro like this with word 2013



hallo, I would like to ask whether is possible to do a macro

the argument is that I have a long text in word 2013, with several length, weight and surface measurements inside (e.g.: 30 meters, 50 tons, 24.5 square meters).

So, I need to find a way to add in the text, concurrently, after these numbers and specific measurement type another number which is the related chinese measuremente

for example:

30 meters, to become in the text after the 'operation': 30 meters (990 jou) - that is the result of 960 is given multipling 30 meters for 32

145 tons, to become in the text after the 'operation': 145 tons (239,751.7 jin) - that is the result of 239,751.7 is given multipling 145 tons for 1653.46

23,000 square meters, to become in the text after the 'operation': 23,000 square meters (34.5 mu) - that is the result of 34.5 is given multipling 23,000 square meters for 0.0015

Of course the automatic operation should be done only by presence of the related words meters, tons, square meters after the numbers, and not with every number in the text

Is that possible to do in word 2013? let me save time and energy

Thanks again for your reply
Reply With Quote
  #10  
Old 04-05-2019, 04:04 AM
macropod's Avatar
macropod macropod is offline word 2013 operation on text Windows 7 64bit word 2013 operation on text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The is no way to automate such conversions in typed text.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically duplicate text for word templates (word 2013) Old Word 1 04-11-2018 11:25 PM
word 2013 operation on text Changing numerals to red in one operation oldyeller38 Word 10 04-27-2015 04:09 AM
video operation tomasball PowerPoint 0 10-29-2010 03:06 PM
word 2013 operation on text Associated operation ECPL_3 Excel 2 10-14-2010 05:29 PM
word 2013 operation on text Basic operation of Excel not working! praveen_p Excel 2 04-23-2009 10:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:08 AM.


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