21,484 questions
1
vote
0
answers
70
views
How to run VBA scripts only in the Word document I'm currently editing? [closed]
I have this code:
Private WithEvents App As Word.Application
Private Sub Document_Open()
Set App = Word.Application
End Sub
Private Sub Document_New()
Set App = Word.Application
End Sub
...
0
votes
1
answer
94
views
How to insert nested fields in VBA for Word? [closed]
I would like to make a VBA macro for Word 2021 that will insert an IF field with STYLEREF fields inside it, to show the beginning and ending paragraph numbers in a page header.
I am able to insert the ...
-2
votes
0
answers
29
views
TOC (Table of Contents) dot leaders and page numbers not aligning properly [closed]
[https://prnt.sc/-yrGCth-33oS]
Hi everyone, I’m having a persistent issue with Word’s Table of Contents formatting and I can’t fix it through styles or tab stops.
In my TOC, the dot leaders stop at 14....
5
votes
1
answer
115
views
Word.Document Close ComException
We have some legacy code that late binds to Microsoft.Office.Interop.Word to do various things with documents.
This code has worked fine for years.
The Solution is written in VB.NET and consists of ...
1
vote
2
answers
115
views
wdFindStop not Stopping Replace at End of Specified Range
I have code that searches for a particular unique pattern and, if found, replaces that pattern. The replace should be limited to the paragraph in which the match is found, but instead it is executing ...
0
votes
0
answers
79
views
async function not executing via Word dynamic menu ribbon button
I have a dynamic menu button in our custom VSTO ribbon. I am loading content to it at runtime. That process is working fine. Dynamic drop down is creating fine. this is the code.
In Ribbon.xml
<...
0
votes
0
answers
29
views
New VSTO Word Add-In unable to start word
I created a new C# VSTO Word-Add in (Framework 4.8.1) in Visual Studio 2022.
Made no modifications at all and then tried to start it (F5), but it ends with this error message:
-------------------------...
0
votes
0
answers
47
views
Word Online Fails to Render Diagrams/SmartArt via WOPI: ResReader.ashx 404 Errors
We have integrated Word Online functionality into our web application using the WOPI protocol to allow users to edit, review and approve Word documents. While standard text documents load and co-...
0
votes
0
answers
81
views
Parsing Word docx file gives "Namespace prefix m on oMath is not defined in Entity" [duplicate]
i am creating laravel project that parsing word doc and docx file into elements in json format. I use phpword library and loading IOFactory::load($path) code. In loading time i get error
DOMDocument::...
1
vote
1
answer
50
views
OpenXML TableRow bottom border hidden by next row
Trying to apply a bottom border to a table row using <w:tblPrEx>, the bottom border is hidden by the next row, even if I give the next row a top border. If I delete the next row the bottom ...
1
vote
1
answer
91
views
Using InsertXML method to modify a Word document in VBA
I need to do some heavy find-replace modifications in a bunch of Word documents and I am trying to speed this up by making this a string operation using the Office Open XML. I can extract the XML ...
0
votes
1
answer
74
views
Mail merge with hyperlinks inside if statement (Microsoft word) [closed]
I am trying to create a mail merge with a hyperlink inside of an “if” statement (the link only appears if a certain mergefield exists), where both the link address and display text are different ...
2
votes
1
answer
71
views
Trying to append hyperlinks (to bookmarks) given a selection in Word
I've got a selection of text highlighted that I want to convert into links (to already created bookmarks that conform to a pattern) in MS Word (Mac if it matters). Right now I'm just trying to append ...
0
votes
3
answers
145
views
VBA Selection.InsertCaption and automatically adding non-breaking space between the label and number
Recently I had the pleasure to review a few specification documents edited in MS Word, containing around 1000 tables and figures, each of those with a caption that did not separate caption label and ...
0
votes
0
answers
26
views
Exceed DocX (Word) Bulletted lists not working?
trying to add a bulleted list of answers under a question, but if I use the code specified in the docs, nothing shows up in outputted file.
Anyone can help?
var idxQuestion = 1;
...
0
votes
1
answer
108
views
Bulk Document Reformatting - VBA Compile Error [closed]
What is wrong with the following VBA module: an attempt to standardise font and layout on over 2000 docx MSWord365 pages to Montserrat SemiBold, 14 pt in justified paragraphs?
Text
Sub ...
0
votes
0
answers
78
views
vba mail merge problem with bullet numbering
I have a problem with some vba code involving a mail merge in word. The program creates a word document and a pdf file and saves them each into a seperate directory. However, I have bullet numbering ...
-1
votes
1
answer
61
views
Error unknown op code for conditional - What am I missing?
I have tried for hours to debug this condition in Word, and I simply cannot see what the error is. Is there a space or something that should not be there?
I am out of ideas what to look for.
I have ...
-3
votes
1
answer
101
views
Extracting Songs from a Songbook (1 year on)
Well, I took a break from this and have now come back. I've got everything to work except one last step.
The songs that have been extracted from the master Songbook and placed in the Gig Book are ...
0
votes
1
answer
73
views
MS WORD VBA - remove extra n.n.n section headings in a marco fails on heading level 1
Sooooo.... I have a situation where I had to recover 1000+ documents from PDF back into word. Most of the documents used heading numbering...
1 Heading One
1.1 Heading Two
1.1.1 Heading Three
etc.
...
1
vote
1
answer
112
views
How do I get the hwnd of Word using PowerShell to show the comparison of two docs?
I've written some code in PowerShell that opens two Word documents in Word and then invokes a Review - Compare.
However, I don't like the way I need to search for the hwnd pointer by looking for a ...
0
votes
0
answers
72
views
Word Interop Find.Execute() modifies the source Range object to a undesired value
I'm using Word Interop Libraries to identify bold text in a Word document and add comments to those sections. However, while running the code, I noticed an issue(from the Word UI): when a bold part or ...
0
votes
0
answers
71
views
How do I use a macro in vb to loop the contents of a directory? [duplicate]
I've created a macro that works on any open .docx file.
I'd like my VBA code to point a MS word macro to a directory and apply it the macro to all .docx files.
Is there a snippet that I can put in the ...
0
votes
0
answers
36
views
Prevent SharePoint Word documents from being opened in the desktop application
I'm working on a SharePoint Embedded solution which, among other things, creates Word document view/edit links using the Graph API endpoint createLink : https://learn.microsoft.com/en-us/graph/api/...
0
votes
2
answers
75
views
Microsoft Word formulae: How check if fields are valid before adding them in next calculation
I have a MS Word template that is used to produce Invoices.
It contains two table ('LabourTable' & 'PartsTable').
At the end of each table is a Total. Produced by the formula: {=SUM(above)}
...
0
votes
1
answer
125
views
How to fix "object/block variable not set" error?
I'm trying to use VBA on Word 2013.
I'm on Win10.
I created a macro a long time ago to format documents to how I want them.
But,now, when I click to run the macro, I get: "OBJECT VARIABLE OR ...
1
vote
1
answer
141
views
VBA macro to accept track-changes deletions gets stuck
(edited to clarify which macros I tried)
I have an MS Word docx with tracked changes, and I'm trying to accept all track-changes deletions, while leaving tracked-changes insertions as they are (i.e., ...
0
votes
1
answer
56
views
Doc4j corrupts docx file after inserting paragraph
I am trying to add a simple text paragraph with text ""Hello from Java test!" in an existing simple docx file (contains only one dummy line of text already) using docx4j.
But when I am ...
0
votes
0
answers
61
views
MSWord VBA for verification to add initial/signature
I am trying to add Label in MSword with just clicking macro that been set in module event handler. The Label is for time and date but just for one macro.
However , if I click macro multiple time for ...
0
votes
0
answers
82
views
Word tables don't merge when deleting data between them
I have 2 Word documents, each with 2 tables in them separated by a paragraph mark. The tables are simple but different # rows and columns. I want to merge the two tables in each document. In docA, I ...
2
votes
1
answer
119
views
Having a macro wait 2 seconds then Alt-Tab and SendKey
I have tried various methods with no luck
Sub Pad()
Sleep 3.5 * 1000
SendKeys "=anything", True ' Get grand total.
SendKeys "%{F4}", True ' Send ALT+F4 to close ...
1
vote
1
answer
107
views
Formatting a word table created in excel using VBA
I have a table like this excel table and I want to create a Word Table to look like this
I am a novice user of VBA so this is genuinely killing me because I can't figure out how to make this happen.
...
0
votes
1
answer
59
views
Auto-sizing the Heading of a Word Document
I am creating a Word document using C# and Word Interop plus a default word template. However, in some cases the code needs to create a document title containing a long word (the file name of another ...
3
votes
0
answers
86
views
How can I set the number of pages per sheet in a Microsoft Word macro using VBA?
I am trying to automate a print job for a word document that I run daily. The task is executed as 7 print jobs on a 3 page document and requires differing sizes for the document. This is my desired ...
-2
votes
2
answers
122
views
Create new documents based on questionnaire logic
I am trying to create separate documents for each country I will send a questionnaire to, and I am struggling. Basically, I have a master document with this questionnaire:
ASK CANADA, GERMANY, ITALY
...
1
vote
2
answers
153
views
Using Docxtemplater horizontally expand nested loop in a MS Word Table
We have data that looks like this:
[
{
firstName: 'Susan',
lastName: 'Storm'
meta: [
{
age: 30,
email: '[email protected]'
}
]
},
{
...
0
votes
0
answers
113
views
Creating an email with word document as template - does not work in W365
I have some code previously used to open an email .oft file, replace some text with data in the excel document and display the email.
This code works, but in W365 virtual machine it does not. I've ...
0
votes
1
answer
65
views
Word VBA: Why merely reading List.Range property changes the document (and adds "Bullets and Numbering" item to undo stack)?
I am experiencing surprising behavior from MS Word (version 2007).
Steps to reproduce:
Open a blank Word document.
Create a list (numbered or bulleted, does not matter) and type at least one item ...
1
vote
2
answers
39
views
Macro for multi word or phrase find and apply comment bubble with specific comment
Looking for help as I'm trying to find a way to get a macro to find a specific word or phrase and, if found, apply a comment, if not found to move on to find the next word and apply comment. I want ...
1
vote
1
answer
94
views
Create then save Word doc with variable name to OneDrive using Excel VBA
I have code to create a new Word document then copy and paste information from Excel.
It then needs to check if a file exists with a specific filename from variables from the Excel sheet and if not ...
0
votes
0
answers
111
views
Create Google Word Doc programmatically in PHP
I have some data in a MySQL database which I am spitting out using PHP.
I want to have this data inserted into a Google Docs Word document programmatically for the end user to finally edit it at their ...
0
votes
0
answers
68
views
Modular way to handle object that could be either Selection.ChildShapeRange or Selection.ShapeRange
I am puzzled about a modular way to handle an object that could be either Selection.ChildShapeRange or Selection.ShapeRange in Word 2013. The former applies if the user has selected a shape within a ...
0
votes
0
answers
64
views
Function as_flex_table() Corrupting Word File when Knitting
The function as_flex_table() is causing my Word files to be corrupted when I knit to Word using R Markdown, despite the code running fine within R Studio.
The following code knits to Word with no ...
1
vote
0
answers
65
views
Word Addin - Get version from the manifest file
We have developed a Word Add-in using Angular and are currently using OfficeJS for performing Word-related operations.
We want to programmatically access the manifest version (i.e., the version ...
2
votes
1
answer
85
views
Convert Microsoft Word docx to html using Apache POI
I have to convert word docx files to html keeping the html format exactly the same as if it was converted by word itself. It will run in a production server where Office (Microsoft, OpenOffice, ...
0
votes
0
answers
24
views
Using Word on a Mac. Mail merge ELSE IF function with paragraph entered causes the paragraph to lose its autonumber
I'm on a Mac, and using Desktop Word. Here is screenshot of my document with the Mergefield (not what I want to do, but shows the problem I'm trying to solve)
This works
Now, onto what I'm try to do. ...
0
votes
0
answers
81
views
OpenXML Thumbnail for Word Document
I have this code to create a Thumbnail for a Word Document (.docx) and return the .jpg as a Base64 string.
The result does not seem to be a valid .jpg
I want just the first page.
I have seen an ...
-3
votes
3
answers
321
views
Efficient mass find-replace in Word via VBA
I have a VBA-based tool that basically for each row in the Excel takes a defined word document and performs number of find-replace operations. This has been working well so far, but I am starting to ...
0
votes
1
answer
54
views
Prevent VSTO .msi installation if Word is running (check winword.exe)
I'm developing a VSTO add-in for Microsoft Word and packaging it using a .msi installer (Visual Studio Installer Project). Before proceeding with the installation, I want to ensure that Word (winword....
0
votes
1
answer
65
views
MSAccess VBA Find Text in Word Document Select All Text After Find
I want MS Access to search for text in a Word document and then, when it has found the text, select all of the text following the find to be analysed further within Access. I have the code working ...