473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to assign replacement text to string Variable?

In the following example I am doing a find and replace using a macro inside Word. At the bottom you can see that I assign the searched for text to the variable sText. How would I assign the replacement.text to a variable? So for example in this case the macro finds "To:" and replaces it with o. I would like to be able to assign "o" to a variable


Expand|Select|Wrap|Line Numbers
  1. Sub Macro6()
  2. '
  3. ' Macro6 Macro
  4. '
  5. '
  6.     Selection.Find.ClearFormatting
  7.     Selection.Find.Replacement.ClearFormatting
  8.     With Selection.Find
  9.         .Text = "T(o):"
  10.         .Replacement.Text = "\1"
  11.         .MatchWildcards = True
  12.     End With
  13.     Selection.Find.Execute
  14.     With Selection
  15.         If .Find.Forward = True Then
  16.             .Collapse Direction:=wdCollapseStart
  17.         Else
  18.             .Collapse Direction:=wdCollapseEnd
  19.         End If
  20.         .Find.Execute Replace:=wdReplaceOne
  21.         If .Find.Forward = True Then
  22.             .Collapse Direction:=wdCollapseEnd
  23.         Else
  24.             .Collapse Direction:=wdCollapseStart
  25.         End If
  26.         .Find.Execute
  27.     End With
  28.     sText = Application.Selection.Text
  29. End Sub
Sep 29 '13 #1
0 1053

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Brian | last post by:
Hello, I am trying to work out how to have smarty use a string's contents as the display-> template.. ie: $smarty->display($buffer); obviously $buffer isn't a filename, but a smarty template...
2
by: MatrixCrawler | last post by:
Hi there, i just wondered if it is possible to handle a string variable as a mathematical order. If the variable contains i.e. "2*100" PHP should calculate it, so that i'm able to assign the...
2
by: Martin Feuersteiner | last post by:
Hi I'm grateful for any light you can shed on this!! I've to admit, it's an unusual design but I've multiple contact tables named e.g. i2b_ash_contact or i2b_ted_contact. 'i2b_' and...
1
by: Martin Heal | last post by:
I am having problems trying to assign the contents of a Memo table field to a String variable in VB using the following code: Private Function udfBuildSQL(SQLID As Integer) As Variant Dim rs...
1
by: Hose B | last post by:
HI all, I have a legacy app in which users can pick various page templates. There is a template preview dialog. It works such that they view a list of icons in an asp page that represent each...
2
by: Jordan Richard | last post by:
Put another way, is there any way I can tell ASP.NET to convert a path (imbedded in a string variable, "~/images/some_image.gif") to a root-relative path, that the client will understand, for the...
2
by: Jason C Reynolds | last post by:
Hi, I've came up short on an answer to this: Is there a way to find out if a string variable contains valid rtf text? I got around by trapping the error and just setting the .text property instead...
3
by: ad | last post by:
I have a text file in the directory of my web application. How can I read this text file into a string vaiable?
3
by: David | last post by:
Hi, how to convert a char array(byte) to a string variable? byte buffer; string strTest; /*the blow codes all get type of 'buffer': System.Byte! strTest = buffer.ToString() strTest =...
0
by: =?Utf-8?B?cm9uZSBtYXRpYXM=?= | last post by:
I have the same task to do but everytime I tried to parse my code I get a null value returned after executing "dtMaterials.WriteXml(swMaterials);". I am using the following code: Hope you can hep...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.