All Questions
Tagged with vba microsoft-word
278
questions
0
votes
1
answer
73
views
I want my macro to find all words (in a certain unformatted document) that start with a certain string ("yyy") give these words a different formatting
I want to find all words (in a certain unformatted document) that start with a certain string ("yyy") and give these words a different formatting.
The following VBA-code executes once and ...
0
votes
1
answer
231
views
Removing Content Control Quick Part in Microsoft Word
I have a VBA macro that will auto populate a document with content control quick parts that have blocks of text with other content controls within them.
I'm attempting to write a VBA macro that will ...
1
vote
0
answers
73
views
Unique ID for Fields and Cross References in Microsoft Word
I am working with a collaborative Microsoft Word Document with Figures and Tables cross referenced throughout the document. For instance, there are 75 figures linked with Captions. We have cross ...
1
vote
0
answers
188
views
How to run a Word macro from the command line?
I'm trying to save and close all open Word files (to start I only target one of them).
The macro I made works when ran from Word (clicking "Execute"), but it won't run when called from the ...
0
votes
0
answers
51
views
extract VBA userform from corrupted word docm
I have a userform in word built over 10+ years. Today Word chose to crash the normal.docm file and the VBA project became unreadable.
I have used python scripts to extract the code, but I don't have ...
1
vote
2
answers
304
views
How to insert username in system username format in Word using field code
I want to insert current username via field code. There is a field code UserName. This field code's return value is like Application.UserName in VBA i.e., "Super User". I want the return ...
0
votes
1
answer
212
views
Word VBA: How to check if the window "in focus" is a protected view or not
In my Word VBA AutoOpen Sub, I want to check if the opened document has been opened "normally" or if it has been opened in protected view.
However, if I use ThisDocument.Application....
0
votes
1
answer
970
views
Word macro: Insert text into each selected cell of a table
I am trying to format cells and insert text (in this case a checkbox) in each SELECTED cell in a table. This is used as a place keeping aid in my plant emergency procedures. The cells format properly, ...
0
votes
1
answer
124
views
How to bulk edit Word document so all the Chinese characters are placed in the same vertical position?
This is the Word document I received. I need to find a way to put all the words into three lines (ideally), where all the Chinese and phonetic symbol lined up vertically. How can I do that?
0
votes
0
answers
55
views
Excel VBA - Words are not Replacing but PDF is generating
In this code I'm trying to replace specific words targeted by "#" in a template ms word file then generate a PDF and save the file but the problem is......PDF is generating but words are not ...
0
votes
1
answer
264
views
How to remove a command from a Word right-click menu
I've got four commands,Translate, Read Aloud, Link, and New Comment, in the Microsoft Word 2021 text right-click menu that I will never use just wasting space. How can I remove them?
I've found code ...
0
votes
1
answer
348
views
My macros is disabled when I open a Word document via VBA in Access?
I have made a special template for the Word documents I create via VBA in Access - the problem is that the macros in that template are disabled !
If I create a new document by clicking the template ...
1
vote
1
answer
561
views
Create a macro on Word to save with current name at a different location
I have a Windows 10 PC.
Basically I have a similar problem to this: How can I save a file to two locations at the same time?, but just the opposite. I have files on a USB stick, and I want them to be ...
0
votes
1
answer
95
views
Change text color of URL in Word VBA
After the URL is displayed beside the hyperlink, the formatting from the hyperlink is applied. Is there a way to remove the blue, bolding and underline formatting for the URL.
Current format:
My ...
0
votes
2
answers
285
views
Insert URLs in plaintext after each hyperlink in MS Word using VBA
I would like to automatically insert the URL for each hyperlink in a word document beside the linked text.
For example instead of having:
my hyperlinked text
It should be:
my hyperlinked text (https://...
2
votes
0
answers
45
views
Why does certain data imported from Word into Excel have yellow font, but not in Word?
Students fill out some tables in Word, and they must occasionally use a certain color font to get full credit. I'm using VBA to import their data and the color of their font from their submitted ...
1
vote
1
answer
667
views
Word 365 Allow Macros to run on Read-Only/Protected View
I am attempting to upgrade our company to Microsoft 365 x86 from Office 2019x86. We are currently stuck on 32bit because our electronically controlled document process currently has VBA macros that ...
0
votes
1
answer
112
views
Word VBA Regex replacement text inserted to wrong place
I have a Word template with a macro that makes text replacements. But it pastes the replacement text to the wrong place. However, using the Word Search/Replace function manually (Ctrl + H; "Use ...
0
votes
0
answers
226
views
How can I declare current page in vba macros word?
I want to know how to declare between current page, next page and a counter.
I have this code:
Dim docNew As Document
With ActiveDocument
Set Rng = .GoTo(What:=wdGoToNext)
Rng.Collapse ...
0
votes
1
answer
366
views
How to put a Textbox on all word pages (No Header)?
I try to add a text box on each page to be able to modify in my own way (later) a book where it has "correct answers on that page (the pages will be on a specific page that I will not know until ...
0
votes
1
answer
346
views
Word VBA building blocks not immediately available at program start
I am using some shapes in a document, and recently switched from creating these on the fly (slow!) to using building blocks. I insert the blocks via VBA code, from a form.
The building blocks are ...
2
votes
1
answer
147
views
Trying to make CommandButton in Microsoft Word open a hyperlink
I have been having trouble trying to make a CommandButton object in my Word document redirect me to a website on click.
I have tried using VBA code like this:
Private Sub CommandButton2_Click()
...
0
votes
1
answer
44
views
How can I add vertical space before all instances of a particular style in Word?
In my Word document I'm trying to find a way to prefix any instances of the "Heading 2" (no matter what the actual text of the heading is) with a paragraph mark and 2 carriage returns.
I'm ...
0
votes
1
answer
213
views
How to convert a single row into multiple on Microsoft Word?
I have a table with separate rows in which every single row contains lots of English and their Turkish equivalents.
Each row has lots of Turkish sentences on the right cell and each Turkish sentence ...
1
vote
2
answers
5k
views
How to assign VBA to a keyboard shortcut in Microsoft Word?
Okay this sounds silly. I am trying to assign a Macro to a keyboard shortcut in Microsoft Word.
Let's say I want to assign macro LangUS to a keyboard shortcut
I want to assign the macro to shortcut ...
0
votes
1
answer
58
views
Is it possible to map strings obtained by a macro, which contain XML tags, to existing Word styles?
From a macro, I'm obtaining a string like the following:
<p>D. W. Arning et al. <i>Mixed Mode–Mixed level Circuit Simulator</i>. (2011). Ngspice. [Online]. Available: http:..., ...
0
votes
0
answers
171
views
How to create custom Word dictionaries from .CSV files
I work with documents that use a lot of specific words that are flagged by the spell checker in Microsoft Word, such as scientific names of insects.
Ideally, I would take data in .CSV format, and be ...
0
votes
0
answers
71
views
Macro or VBA to reuse or repeat a footnote with user selecting the footnote from the table?
I made a macro to insert the number of an existing footnote, but the captured command in the macro contains the number of the footnote from when the macro was recorded.
I am looking for a method that ...
0
votes
0
answers
320
views
Sub Category Radio Buttons in Word
I have a word document I send to users. In the document there are two groupings of ActiveX radio buttons for users to choose from. I use radio buttons because each of the selections must be mutually ...
1
vote
2
answers
1k
views
Creating a Word macro to type increasing numbers
I'm a Youtuber, and I frequently create word documents that mark where I would like to insert images, videos, or sound bites, corresponding with certain words in the script, to illustrate the points I'...
3
votes
0
answers
473
views
Word VBA: Automating bookmark generation for individually numbered paragraphs
1. Problem summary
This is my first time writing VBA for Word. I have multiple documents; each one is larger than 100 pp., with a plaintext index according to paragraph number. I am writing a script ...
0
votes
0
answers
1k
views
Having trouble with VBA adding page numbers plus text in Word Header
Nothing more humbling than a simple VBA problem that takes all night. I would like to add page numbers to the header of a multi-page document. I have set uo recto/verso pages and no header on primary ...
1
vote
2
answers
993
views
Word VBA select all left indented paragraphs to format text
I want to change the font colour of all left indented paragraphs (in documents exported as rtf from another program). The paragraphs dialog shows they are all indented by 7.94 cm.
I have done this by ...
1
vote
0
answers
52
views
Have 'Heading 4' keep with next, if next is 'Heading 5', but not in other instances
I've got a Word document which is a rule book. To get the enumeration done, for different levels in the rules (rule 1, section 3, article 4, subarticle b, subsubarticle 1 etc.) different headings are ...
0
votes
1
answer
1k
views
How to automatically go to the last edited position on file open in Word?
When you open a document, there is a bookmark icon beside the scroll bar, asking if you want to go to the last position. This is the behavior I want, I just want it to execute automatically every time ...
1
vote
1
answer
299
views
ASK fields do not update bookmarks in Microsoft Word template
I am creating a template document for my office that uses a series of ASK fields to populate some bookmarks with pro-forma content.
The only VBA in the template is used to update fields on a new ...
0
votes
0
answers
37
views
Copy data excel in format table word split list in different pages
Hello and thanks in advance for your help.
1- I have a spreadsheet that Sheet1 and Sheet2 have data list of names and ID that change in daily basis in Excel, is it possible a VBA code run copy from ...
0
votes
0
answers
192
views
Word Create Section for Each Row in a Table
Edit: When I talk about sections I mean whatever the MS Word equivalent to LaTeX sections is.
I have a Word Document with a Table.
A
B
C
Title1
something
Title2
foo
Title3
bar
For each row (after ...
1
vote
1
answer
115
views
wdWord and wdExtend commands not working in Excel Macro
I've recently been trying to create a macro to automatically grab data from a word doc and place it in an excel sheet but I've run into a bit of an issue. After having the macro locate the particular ...
0
votes
1
answer
282
views
VBA - Using Excel Variable in Word
I am trying to use a variable defined in Excel in Word. I am using two separate macros, but all the code is written in Excel. I am trying to control Word from Excel.
Here is the code I have in my ...
2
votes
1
answer
124
views
Find blocks with the same format with the find and replace function in MS Word
I am writing a glossary with MS Word and in the text I have interspersed blocks with different formatting. It is something like this (a bit more convoluted in fact):
term /pronunciation/ word type ...
0
votes
1
answer
1k
views
My vba macro for aligning a shape or graphic to the top right corner of the page in word isn't working
Sub alignGraphicElementToTopRightCornerOfPage()
'
' alignGraphicElementToTopRightCornerOfPage Macro
'
'
Selection.ShapeRange.Align msoAlignTops, True
Selection.ShapeRange.Align msoAlignRights, ...
0
votes
1
answer
91
views
Can I do a auto-expanding group in Word, and create it in VBA?
In my (technical) document I have a few blocks (warning/ tip/ note etc), similar to admonitions. A sample is below.
At the moment, they are created manually : a grouped block of a shape, a text field, ...
1
vote
1
answer
150
views
Optimize WORD VBA - If, Case
I implemented this following code to go though 11 dropdown content controls to color 2 cells in a WORD table based on the user entries - RED, YELLOW, GREEN, and no entry.
This seems to slow down the ...
0
votes
1
answer
473
views
Trim all spaces in start all tables cells in document (Mircrosoft Word)
I need clean all spaces in start of cells of all tables in document.
I tried to use and edit the mentioned VBA Macro in the below link but I could not make it work
this one
Sub TrimCellSpaces()
Dim ...
0
votes
0
answers
1k
views
Word VBA - Get Value From Drop-Down List Content Control to Color Cell In Table
Trying to color a cell based on drop-down CC. Here is what I got - not working getting "require object" error. I have added the drop down CC in the document and named and tagged it dropdown1....
0
votes
2
answers
689
views
Extra Paragraph Character After Header and Footer from Quick Part Gallery
If I insert a header or footer from the quick part gallery, it usually adds a standalone paragraph character on the next line.
This is extremely annoying because it requires cleanup every time. Is ...
0
votes
1
answer
463
views
How to fix uneven space between words in Microsoft Word 2016?
I have 8 pages of paragraphs with uneven space between words, I mean, sometimes one, sometimes two or three spaces between words. The uneven space intervals were originated from a macro fro word that ...
0
votes
0
answers
27
views
Conditional formatting - my code is not rendered and directly reflected in the output in MS WORD
I am trying to apply conditional formatting to merge fields on MS Word. I want the bold text when scode = Total.
So I added a mergefield, pressed alt+f9 together, updated the field like below. Note ...
0
votes
0
answers
34
views
Word Time entry table
I am making a timesheet for my employer, and it needs to be in a Word table.
Rows contain the following cells, going across:
Start Time (clock time) / Lunch Duration (# minutes) / End Time (Clock Time)...