Because of lockdown measures, I've recently begun working from home. I work for an editing company, and I'm required to do a lot of reviewing of editor work (in addition to editing, re-editing). This requires me to quickly and frequently toggle between markup (tracked changes) view and final view. I have hotkey macros to do this, but unlike my 2016 version at my office, Word 365 does not retain the current position when I toggle views, but instead it (the display) jumps to the same page on the other view (the cursor does remain), making it so I lose my place and have to spend seconds finding it again. I need to be able to quickly toggle while keeping my eyes fixed on the current cursor position. I've adjusted my macro so it still keeps the cursor on the page, but it nevertheless jumps around within the page. I need the cursor and its displayed position on the page to remain fixed when switching views.
A secondary problem related to this is that when I select words in final view to comment on (or to edit/replace/highlight/etc.), these words are not actually selected as it jumps to markup view (instead seemingly just selecting the one single next word).
This may not be the appropriate place for a question like this, but I didn't know if some finagling with VBA might help me out here or maybe there were just some people with more Office expertise.
Thanks for any help!
Here is my macro. It's extremely basic, and I just did it from "record macro"; I've done very little actual VBA coding. I believe this is equivalent to clicking "all markup" and then pressing CTRL+RightArrow. The ones to show the final and original text are the same except for the .markUp.
Ideally, I wouldn't need any code because it would just be some setting I'm not aware of, but I know they love to change the fundamentals of how staple programs like Word operate between versions just to mess with people.
Sub markUp()
'
' markUp Macro
'
'
With ActiveWindow.View.RevisionsFilter
.markUp = wdRevisionsMarkupAll
.View = wdRevisionsViewFinal
End With
Selection.MoveRight Unit:=wdWord, Count:=1
End Sub
Related
I have been searching off and on, high and low, for many months, to no avail, for VBA code that I can include in my macros to highlight text using the current default highlight color. I have looked through my personal resource books and all up and down the land of Google, including here.
I have a bazillion macros created that highlight text every which way to Sunday, in every possible (basic) color, and they all work great. But sometimes I have a scenario where I want to highlight random text in an ongoing manner, multiple times, in a particular color. Then I'll want to switch colors ... for a while. And switch again ... for a while.
I have keyboard shortcuts (many) for a lot of highlighting options, including the built-in command shortcut to highlight text that I have selected manually. So, for example, I can manually select three words to my left, and use Ctrl+Alt+H to invoke the built-in Highlight command, and it will use the current default color.
But I'm unable to automate that further with a macro. For example, I have used numerous different iterations of macros to highlight text as I'm typing it, or to automatically highlight X number of words to my left, or a line or sentence or paragraph. But with each of those macros, I'm forced to declare a specific color. That means that I then have to have voluminous series of macros to be able to do the same thing with each (basic) color variation. That's fine if I just want to infrequently highlight text in a specific color. But when I know I will be using a specific color for the next, say, 20 or 40 highlights, I'd love to set a default color and then just use a generic highlight command rather than a color-centric command (which is more steps).
After much experimentation, I've finally figured out a way to do it. I'm not sure if this is the most efficient way, but it works!
I have many highlight-centric macros that will use this feature, but here is an example of one of them using this feature. I declared the existing color as a string and then used the string rather than a specific color (which I erroneously thought was a requirement). The following macro allows me to highlight while I'm typing:
Sub honHighlightOnTypingSelectWord_DEFAULTCOLOR()
CurColor = Options.DefaultHighlightColorIndex
Application.ActiveDocument.Application.Options.DefaultHighlightColorIndex = CurColor
Selection.Words(1).Select
Selection.Range.HighlightColorIndex = CurColor
End Sub
Problem solved!
Please help as I am new to Vba and custom style in MS Word 2013.
I want to create a new custom style that provides heading as INTRODUCTION when a paragraph is been selected, and the rest of the text should come in normal style of paragraphs. Is this possible to make it in custom style or should Vba macro be used. If Vba macro is the only option then how can we add this into the particular custom file.
Styles are for formatting only, they don't contain text (such as INTRODUCTION). If I understand your request, you will need a simple macro you can write, or, actually, record.
So, let's say you have a paragraph in your document. You would like to make this paragraph have the "Normal" style. You would like to insert BEFORE this paragraph the word "INTRODUCTION", and give it the style "Heading 1".
Record the Word macro: InsertIntroduction
Position the cursor at the start of the paragraph.
Enable "Record a macro" - varies by release of Word, but, for 2010, View > Macro > Record. Be sure to specify a good name and a carefully thought out Description. Do NOT shirk this step! Put in the Description! If you are going to use it a lot, assign a keystroke to it also, that will save you a lot of time.
Type INTRODUCTION. Using cursor keys (not mouse), select it (perhaps up-arrow, Home, Shift-End). Apply style "Heading 1" (for this, you can use the mouse: Home > Style group > Heading 1 or a keystroke, usually Ctrl-Alt-1).
Arrow down to the next paragraph. Select the full paragraph using the keyboard, not the mouse (perhaps by hitting the F8 key four times, then ESC).
Apply the appropriate style (again, you can use the mouse, but the Normal style is usually linked to Ctrl-Shift-N).
You've completed the steps you wanted, based on your original request. Note that you can add a lot more, of course. But, let's say you're done.
View > Macro > Stop recording.
You've now written a program and it will be saved. Use it going forward. Cool, hunh? And you can write these things a lot faster yourself than asking others "how do I...?"
Like any other program, it can be modified to do more, or fix little errors. Let's say you misspelled INTRODuCTIoN. Tap Alt-F11 to see your program. Adjust.
9 steps seems like a lot, but, believe me, it's easier done than said. Give it a try. Do it carefully. In theory, if you make a mistake, you can simply modify the program to fix it. But, at your level of experience, you may find it easier to simply Stop recording and start over.
To Use Macro
Position cursor at start of relevant paragraph.
Execute macro. If you took my advice and assigned it to a keystroke, just tap the keystroke. If not, tap Alt-F8 to see a list of your macros. Select the one you want, and click Run.
I'm beyond the limits of my kindergarten-level VBA skills so would like to ask if anyone here can help me write a VBA script to help me work stepwise through my Word document and adjust the anchoring position of all the AutoShapes in the document.
I have a 400-page book in Microsoft Word with at least one and sometimes several marginalia (sidenote) on each page in a thin column to the left of the main body text column. These sidenotes are a concise 'pointer' to a particular point made in the body text and need to appear directly to that point's left.
Each sidenote is in its own AutoShape (within a textbox in that shape). The AutoShapes were placed by the author in an inconsistent way. Mostly they are anchored to a position on the page.
However, I need to repaginate. This will cause the body text to flow differently and I need the sidenotes to flow with it (approximately or exactly)!
So before I repaginate I want to make sure I anchor each AutoShape to the paragraph it belongs to and not to the page it is currently on.
I don't know if that can be done automatically, since I don't know how Word could deduce a purely spatial relationship between an AutoShape and a paragraph.
So I'm guessing I have to make do with a "semi-automatic" process. Something like this:
Press a button to start VBA script
Select next AutoShape
Prompt for user to enter cursor in body text where anchor is to be placed
Resume macro
Place anchor for that AutoShape in that position
Change vertical position paramater of AutoShape to "relative to paragraph"
and "0 mm"
(Alternative, not 0 mm but another value deduced to more
accurately position AutoShape)
Change width parameter of AutoShape to
a particular fixed value 37 mm (some of them were a little
inaccurately drawn)
End cycle and go back to beginning to
Select next AutoShape
Hope that is all understandable.
I've tried to record a VBA script to do some of this but have no idea how to build in the user prompt.
Any help much appreciated!
Craig
You may be better off creating a macro that works on one shape at a time, or anchor all the shapes manually (which you're almost doing anyway) and then write a macro to take care of the various parameters and settings you want.
If you really want to prompt the user while the macro is running you'll need to look into modeless dialogs (not possible on the Mac). See this link: http://www.bettersolutions.com/vba/VXV113/SE846743531.htm
Basically, you'd have to create your own dialog and then show it modelessly so that the user could still place the cursor before hitting OK. If you're new to VBA, this could be difficult to set up.
While searching for solutions to this, I found a post on another forum from someone trying to do something very similar. He was developing a set of tools for editors using Word and until I find the ultimate solution I am using his "Shapes" tool which allows me to change parameters on each AutoShape I select at-a-click instead of opening up and closing a dialogue box each time, plus selecting a different tab each time... His tools can be downloaded at his Editors' Toolkit website.
I'm working on a workbook in Excel 2010 that someone else created (I don't know which version they were using) with a button in it that invokes a macro. There are a lot of macros defined, so I'm right-clicking on it to find out which one it calls, but the context menu doesn't appear. Instead, when I click off, the button gets larger. I can make this happen as many times in a row as I'd like. There is another button the same worksheet that has the same context menu problem, but instead of growing, the text shrinks each time. There is another button that functions normally when I do this.
Growing buttons in Excel is a fairly common issue, with several theories about why this happens, including the use of multiple monitors or using proportional fonts. I have yet to see a definitive answer about this, but there are several workarounds that may work for you.
Delete and re-create the buttons.
Programmatically set the height and width of the buttons when the workbook is opened and when a button is clicked.
Select the button with another object or two on the sheet and group them.
Don't use them at all.
My personal choice is #4. As an alternative to buttons, I either use hyperlinks or shapes with macros assigned to them.
I think you want to enter "Design Mode" in the work book:
You should be able to right-click on the button to see what it does after that.
I have this same issue. I have two Excel workbooks with similar buttons on each. This only happens on one of them, but it happens every time I open that file.
I have found a sort of work-around. I open a blank Excel document, then I open the affected one and the buttons do not change size any more. When I open the second one, I have to drag it into the window with the already-open file. If I double-click on it, it opens in a new window and the problem remains.
I have the same issue sometimes. In my case, I could replicate it 100% on one file but it was inconsistent on an virtually identical file. I also found the size error wasn't permanent -- I could save and reopen the file to restore the button's appearance. I could also create a new window and then discard the damaged window.
For me, the button resized when I accessed the sheet's HPageBreaks collection. I was able to avoid the problem by temporarily changing the window view as follows:
ActiveWindow.View = xlPageBreakPreview
' do pagination stuff using HPageBreaks
ActiveWindow.View = xlNormalView
I am working on a Word VBA macro app for 80 or so users. The office has high staff turnover, so training suffers, and so one of the self imposed requirements for this project is comprehensive, friendly documentation. However, to supplement this, and to save newbies having to open up a 100 page document when they want to try something new, I want a status bar on every userform (there are five) that provides contextual help. I find tooltips annoying.
I don't have a lot of experience, so I was wanting to
Essentially, I have a file containing every status string. (This is currently a text file, but I was wondering if I should use a spreadsheet or csv for ease of editing by other staff in future.) Every control has a MouseMove event which refers to a function: getStatus(cID) that opens the file, grabs the line and displays it in the status label. It also grabs a few parameters from the same line in the file, such as whether the label is clickable (to link to a page in the help file), and what colour the label should be.
So a few questions really:
Will the application be slow if a userform is constantly referring to a file? It feels fine to me, but I've been in it far too long, and I'm the only user accessing that file. There will be 80 constantly accessing it.
Is MouseMove over a control the best way? Should I instead use co-ordinates?
Most importantly (in terms of me having to do as little work as possible) is there some way to do this so that I do not have to have a MouseMove event on every single control? I have a good few hundred or so controls, each with their own identifier (well, not yet, but they will if this is the only way to do it). Maybe when the form loads I could load ALL the possible status lines so they're ready for whenever the control is moused over. But then, maybe the loading time is negligible?
Appreciate any ideas or thoughts - especially if VBA already has a whole range of functions to do this already and I'm just trying to reinvent the wheel. I can't use the application status bar, because the user rarely sees the application itself.
Thanks!
EDIT:
It is for both data entry, clicking around and a bit of document generation.
It is a controlled environment so macro security issues aren't a big concern for me - and if something goes wrong it's someone else's fault or problem :)
Is this data entry app or do they just click stuff? Because often the field with focus is different to the item the mouse is hovering over, this can cause a lot of confusion.
Constantly reading from a file is a huge waste of time and resources - it is much better to load them only once into an array or collection when the form is loaded.
On MouseMouse event is better than coordinates because you can move things around without worrying. It's a lot of code but you should be able to generate most of that if you have a list of control names because the code should be identical.
ie
Sub Control_MouseMove()
DisplayStatus(Control)
End sub
I would consider the StatusText property and ControlTipText property of controls for this kind of help.
StatusText
This example sets the status bar help text for the form field named "Age."
With ActiveDocument.FormFields("Age")
.OwnStatus = True
.StatusText = "Type your current age."
End With
ControlTipText
This can be assigned from the property sheet for the control.
Private Sub UserForm_Initialize()
MultiPage1.Page1.ControlTipText = "Here in page 1"
MultiPage1.Page2.ControlTipText = "Now in page 2"
CommandButton1.ControlTipText = "And now here's"
CommandButton2.ControlTipText = "a tip from"
CommandButton3.ControlTipText = "your controls!"
End Sub