How do you change a name mentioned multiple times in a region - vb.net

I wanted to know if there's shortcut to change a name like "tom" to "sally" in a region in Visual Studio 2013. I have about 40+ tom's and to change it manually takes forever. I'm using vb.net. Any help is much appreciated.

Other than using a find and replace (CTRL+H), you can use a text editor like sublime text:
https://www.sublimetext.com/

You can limit the replacement to a selected region of text. In the Find/Replace dialog there is a "Look In" drop down. If you have text selected, you will have the option "Selection" It's only visible when you have selected text which is confusing/misleading (why not just disable?).
You can then use replace all, and the replacement will be limited to the selection region.
If you collapse a code region you can select the entire region easily.

Related

Can I use the Shrink Method for the whole document in word

I don't know anything about code. I work with e-learnings in Storyline 3. I sometimes localize these e-learnings and use the translation tool in Articulate which basically exports an MS Word file. Sometimes the target languages are longer and I need to decrease the font size by percentage for the whole document. Usually, there are at least 3 different font sizes that I need to decrease accordingly. I am wan to develop a macro that I will use for multiple documents.
I couldn't find a way to do this by percentage, but looks like the Shrink or Grow Methods will do the work! I found this code in the reference page but looks like it works only for a selected object. The issue is that the exported MS Word file is in a table with each text box in the storyline separated to a cell. When I select the whole table it does not work.
If Selection.Type = wdSelectionNormal Then
Selection.Font.Grow
Else
MsgBox "You need to select some text."
End If
Could you please help me and let me know if this would be possible for the whole document, or the selected table? It would be very much appreciated. Thanks in advance.
It is unclear from your question whether the table in the Word document contains the actual text boxes or just the text they contain.
If it is just the text then Shrink may work. I tested this on a document with a single table containing only text:
ActiveDocument.Range.Font.Shrink

VBA - Word Table : default value and combo box

I have Word Tables, and I don't find how to affect default values for certain columns...
When inserting a new line, I would like a certain column to have a certain drop-down list without user having to do it himself.
To illustrate my thoughts, here is a small image of what I'm looking for
I really don't find how to manipulate my table for it to ends up like this, so I would like to request your help.
When looking on the web for this, I only find information about table default style and no default Value.
So I would like to ask. Is this possible? If yes, how to do it?
I am looking for either a VBA code to set my column default value (which would be great), or even a way to do it in Word GUI at first. Or, obviously, an answer that would tell me that it is impossible to do in Word.
PS: the extremely easy equivalent in Excel of what i'm looking for:
Thanks in advance!
In the GUI:
Click the cell where you would like your dropdown.
In menu, switch to "Developer Tools"
Insert a Dropdown control ("Controls" are, the one in the middle)
In the ribbon, click "Design mode" (I have German Word so the actual name might differ), "Properties"
Now you can enter your options
Alternatively via VBA, I got this with the macro recorder; should give you a start:
[Cell].Range.ContentControls.Add (wdContentControlComboBox)
ActiveDocument.ToggleFormsDesign
Selection.ParentContentControl.DropdownListEntries.Clear
Selection.ParentContentControl.DropdownListEntries.Add Text:="Yes", Value _
:="Yes"
Selection.ParentContentControl.DropdownListEntries.Add Text:="No", Value:= _
"No"

How to select all instances of a variable and edit variable name in Sublime

If I select a variable (not just any string) in my code, all other instances of that variable get a stroke (white outline) around them:
Is there a keyboard shortcut that will let me select all of those instances of the variable and edit them all at once?
Things I've Tried:
⌘D, ⌘K, and ⌘U lets me select them one-by-one, but I have to manually exclude the non-variable string matches:
And using Ctrl⌘G simply selects all the string matches:
Clearly, Sublime is able to differentiate between variable and string matches. Is there no way to select just the variable matches?
Put the cursor in the variable.
Note: the key is to start with an empty selection. Don't highlight; just put your cursor there.
Press ⌘D as needed. Not on a Mac? Use CtrlD.
Didn't work? Try again, making sure to start with nothing selected.
More commands:
Find All: Ctrl⌘G selects all occurences at once. Not on a Mac? AltF3
Undo Selection: ⌘U steps backwards. Not on a Mac? CtrlU
Quick Skip Next: ⌘K⌘D skips the next occurence. Not on a Mac? CtrlKCtrlD
Sublime Docs
I know the question is about Macs, but I got here searching the answer for Ubuntu, so I guess my answer could be useful to someone.
Easy way to do it: AltF3.
Despite much effort, I have not found a built-in or plugin-assisted way to do what you're trying to do. I completely agree that it should be possible, as the program can distinguish foo from buffoon when you first highlight it, but no one seems to know a way of doing it.
However, here are some useful key combos for selecting words in Sublime Text 2:
Ctrl⌘G - selects all occurrences of the current word (AltF3 on Windows/Linux)
⌘D - selects the next instance of the current word (CtrlD)
⌘K,⌘D - skips the current instance and goes on to select the next one (CtrlK,CtrlD)
⌘U - "soft undo", moves back to the previous selection (CtrlU)
⌘E, ⌘H - uses the current selection as the "Find" field in Find and Replace (CtrlE,CtrlH)
This worked for me. Put your cursor at the beginning of the word you want to replace, then
CtrlK, CtrlD, CtrlD ...
That should select as many instances of the word as you like, then you can just type the replacement.
The Magic is, you have to start with an empty selection, so put your cursor in front of the word/character you want to multi-select and press Ctrl+D .
To me, this is the biggest mistake in Sublime. Alt+F3 is hard to reach/remember, and Ctrl+Shift+G makes no sense considering Ctrl+D is "add next instance to selection".
Add this to your User Key Bindings (Preferences > Key Bindings):
{ "keys": ["ctrl+shift+d"], "command": "find_all_under" },
Now you can highlight something, press Ctrl+Shift+D, and it will add every other instance in the file to the selection.
As user1767754 said, the key here is to not make any selection initially.
Just place the cursor inside the variable name, don't double click to select it. For single character variables, place the cursor at the front or end of the variable to not make any selection initially.
Now keep hitting Cmd+D for next variable selection or Ctrl+Cmd+G for selecting all variables at once. It will magically select only the variables.
It's mentioned by #watsonic that in Sublime Text 3 on macOS, starting with an empty selection, simply ⌃⌘G (AltF3 on Windows) does the trick, instead of ⌘D + ⌃⌘G in Sublime Text 2.
At this moment, 2020-10-17, if you select a text element and hit CTRL+SHIFT+ALT+M it will highlight every instance within the code chunk.
Just in case anyone else stumbled on this question while looking for a way to replace a string across multiple files, it is Command+Shift+F

Creating OpenerView in a Notebook for Various Section of the Notebook in Mathematica

I have a notebook with various sections which I would like to contract (i.e show only the title of the section/subsection etc...) and expand as needed to reveal more or less of the content of the various parts (as done in the help section of Mathematica for instance).
I see the function OpenerView creates the icon but appears not to be suited for the purpose.
How do I accomplish that?
From the menu, try "Format->Option Inspector" and select "Selected Notebook" from the drop-down menu. Then in the search box type "opener", and make sure the "ShowGroupOpener" is checked. Then put the parts of your document into "Sections", "Subsections" etc. using the "Format->Style" menu options.
The blue brackets on the right side of the page are cell brackets. They show you want can or will be collapsed. Double click the one that surrounds the block you wish to collapse, or select the section and press: Ctrl+'
If you wish to expand or collapse all of the sections within a section or notebook, select the range you want to affect (Ctrl+a to select all), then use:
Ctrl+Shift+[ to open
Ctrl+Shift+] to close
In the menu Cell>Grouping if Manual Grouping rather than Automatic Grouping is selected, then the sections you want to collapse may not actually be grouped. You can see what is grouped or not, by the blue brackets on the right side of the Notebook. This is what I attempted to allude to above. If you change the setting to Automatic Grouping, or group the cells manually using Ctrl+Shift+g, you should see the brackets indicate the group, and the commands above should work.
If you refer to this post,
https://mathematica.stackexchange.com/questions/265/easiest-way-to-use-showgroupopener-in-mathematica
it will likely have your answer. To enter the expression for the cell, use Cell | Show Expression. There you can turn on the ShowGroupHeader option.

Using VBA in MS Word 2007 to define page elements?

I'd like to be able to create a page element which I can feed text and it will form itself into the preferred layout. For instance:
{MACRO DocumentIntro("Introduction to Business Studies", "FP015", "Teachers' Guide")}
with that as a field, the output should be a line, the first two strings a certain size and font, centred, another line and then the third string fonted, sized and centred.
I know that's sort of TeX-like and perhaps beyond the scope of VBA, but if anyone's got any idea how it might be possible, please tell!
EDIT:
Ok, if I put the required information into Keyword, as part of the document properties, with some kind of unique separator, then that gets that info in, and the info will be unique to each document. Next one puts a bookmark where the stuff is going to be displayed. Then one creates an AutoOpen macro that goes to that bookmark, pulls the relevants out of the keywords, and forms the text appropriately into the bookmark's .Selection.
Is that feasible?
You're certainly on the right track here for a coding solution. However, there is a simpler way with no code - this is the type of scenario that Content Controls in Word 2007 were built for and with Fields/Properties, you can bind to content controls (CC). These CC can hold styles (like centered, bold, etc.). No VBA required.
The very easiest thing to do is to pick 3 built-in document properties that you will always want these to be. For example, "Title" could be your first string, "Subject" your second string and "Keywords" your third. Then, just go to the Insert ribbon, Quick Parts, Document Properties and insert, place and format those how you like. Then go to Word's start button (the orb thingy) and then under Prepare choose Properties. Here you can type, for example "Introduction to Business Studies", into the Title box and then just deselect it somehow (like click in another box). The Content Control for Title will be filled in automatically with your text.
If you want to use this for multiple files, just create this file as a .dotx (after CC insertion/placement/formatting and before updating the Document Properties' text). Then every time all you'll have to do is set these three properties with each new file.
Well, yes, it did turn out to be feasible.
Sub autoopen()
Dim sKeywords As String
sKeywords = ActiveDocument.BuiltInDocumentProperties(4)
ActiveDocument.Bookmarks("foo").Select
Selection.Text = sKeywords
End Sub
Okay, I have some filling out to do, but at least the guts of it are there.