FAQ Database Discussion Community


XML to Word using custom paragraph styles and XSLT

xml,xslt,ms-word
I've got an XML file that contains mostly textual information (list of questions in Moodle XML format). I'd like to convert it to a document that can be opened by MS Word, but I'd like to maintain context (using paragraph styles) so I can convert it back to Moodle XML....

Extracting data from Excel to Access Database

database,excel,ms-access,ms-word
There is a standard company form currently in Word format (could use a different technology) with fields. How do I extract the data into my Access DB from this fields?. I am also open to advice of which technology would suit my requirements better with the requirements being: Need document...

Macro in Word to Underline each paragraph in document less than X characters long

vba,ms-word,ms-office,word-vba
I have a word doc of several pages. There are many lines in the document that are short headings, then the carriage return, then a descriptive paragraph. Not front page news. eg Condition Subsequent A condition subsequent is often used in a legal context as a marker bringing an end...

How to identify a particular text box?

textbox,ms-word,word-vba,word-2013
My VBA routine is deigned to alter text in a text box in the document's footer. Right now it is identified as follows: Dim R1 as Word.Range Set R1 = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range R1.ShapeRange(1).TextFrame.TextRange.Text = "xxxx" However, users may modify this template and possibly add other text boxes. How do I guarantee...

Word Vba Userform textbox onChange

vba,ms-word,word-vba
I have a userform have one textbox field and with ok and cancel button for myRun macro: Sub myUserForm() UserForm1.TextBox1.Value = Selection.Font.Size UserForm1.Show End Sub And for my Form marco: Private Sub TextBox1_Change() Dim myValue As String myValue = UserForm1.TextBox1.Value If Not IsNumeric(myValue) Then MsgBox "Please enter a number" MsgBox...

How to add a word file content to a crystal report?

c#,visual-studio,crystal-reports,ms-word,converter
I am working on a web application project in visual studio Ultimate 2013. In this project, I am using crystal report templates where I need to design a template for a long word file (15 pages long). My question is: (Is there any possible way to add the word file...

Automating usage MS Word as PDF to HTML converter [closed]

pdf,ms-word
I have a task to convert several hundred PDF documents to HTML format. I have tried multiple standalone converters, but they have problems with handling columns and hyphen justification. However, if I just open a document in MS Word, it handles them perfectly. So, basically, I need a way to...

Mail Merge from Multiple SQL Tables

sql-server,ms-word,mailmerge
We have three tables TABLE1, TABLE2 and TABLE3. TABLE1 has primary key TABLE1_PK which is a foreign key for other two tables. We have a document in MS-Word, which fills the data from these three tables columns based on the TABLE1_PK. In MS-Word we found the mail merge option...

Vba Ms-Word Nested Error Control

vba,error-handling,ms-word
I'm trying this time to handle errors between nested subs. For example: Sub A() On Error GoTo errormsg Call B Call C Exit Sub errormsg: MsgBox "Error in A", vbOKOnly, "Warning" End Sub Sub B() On Error GoTo errormsg Call D Exit Sub errormsg: MsgBox "Error in B",vbOKOnly,"Warning" End Sub...

Reading a TXT File with VBA suddenly doesn't work anymore

vba,ms-word,word-vba
I am in the process of converting some old Macros from Word 2003 to Word 2013. I thought I would only have to build a fancy Ribbon Bar and be done with it, but apparently not. The following code is supposed to read the whole content of a TXT File...

Insert and activate a phone number in a generated word document

c++,vba,ms-word,ms-office
I would like to add a phone number to a word document that I generate using the mso api. In word, when one writes (Tel:00493298402938) and new line, the phone number is activated automatically. While trying to record the corresponding macro and check the VBA code, it doesn't show the...

How to fill the rest of line with space() / string()?

excel,vba,ms-word,word-vba
I am generating a word document filled with user inputed values (userform input). Is there any way to fill the space after typed value with amount of whitespace required to fill the rest of the line? Or how to get the amount of characters left to the end of line?...

Copy and Paste Hyperlink change path to absolute

hyperlink,ms-word,ms-office,copy-paste,word-2010
I just want to copy the Hyperlink from one Word document to another, but after copy/paste Word change address from relative to absolute. Explanation: In document_1.docx hyperlink is with this parameters: Text to display: This is link to the document Staff Address: files/staff.pdf After c/p in second document (or on...

MS Word Macro to replace all hyperlinks with a single word

vba,hyperlink,ms-word,word-vba
I prepare a MS Word file with a large amount of news articles, each followed by a full, long clickable hyperlink (e.g. http://www.newssite.com/this-is-the-name-of-the-article.html). I need to replace all the hyperlinks in the file with a single word: "Link", while keeping their url adresses and click functionality. I can use MS...

How to insert custom page number in Aspose.Words

c#,c#-4.0,ms-word,aspose.words
I want to add custom page numbers (like 1/2,2/2) to word document with using Aspose.Words. But I couldn't find any sample for c# language. I tried to overrite footer but i couldn't give a format to page numbers. Pls help! Thanks! edit After i tried first answer,it worked as what...

Regular Expression in Word VBA

regex,vba,ms-word
I have the following regular expression syntax in VBA for MS Word which works: regEx.Pattern = "\w*\(\w*\s[0-9]{1,3}:[0-9]{1,3}(\)|\-[0-9]{1,3}\))" MsgBox regEx.test("This is a test (Chronicles 13:12-14)") This returns True, as desired. I encounter difficulty when I attempt to include patterns for "First", "Second", "Third", 1, 2, 3, or nothing immediately following my...

Apply a TableStyle to a Word Table

c#,ms-word,openxml,docx
Trying to style a table using a predefined style but nothing is working. I've tried with a a newly created document and one created from a saved template. Using the SDK Productivity tool I can see the style is there in the template but it's not being applied. I've tried...

Formatting Marks also show and hides tables

excel,vba,excel-vba,ms-word
I have a weird bug. The below report is built from from a complex Excel Macro and below is a single page from the report output. The page is built from a range so the report is all in tables which is fine. https://drive.google.com/folderview?id=0B-A_d72xVQXtfmVQUFFHdmVvUUdldUpLT1dmRnk4bXowaDNtUWt0eE5yeE1mZHRKNEpyck0&usp=sharing The problem I am having is...

How to Expose Listbox in UserControl in CustomTaskPane VSTO C#

c#,ms-word,vsto
I am creating an application level add-in for Word 2010 using C# VSTO. I created a User Control, placed controls within it, and then used the User Control to add a Custom Task Pane: UserControl myUserControl; myUserControl = new PageElementsPane(); mytaskPane = this.CustomTaskPanes.Add (myUserControl, "Page Elements", doc.ActiveWindow); So far so...

Microsoft Word 2010 VBA: Using regex to find and replace

regex,replace,ms-word,word-vba,pci
I'm trying to allow our staff to quickly mask the middle 8 digits of credit card data in old documents. I figure a macro using regex to do a find and replace is the fastest way for them. Masking is a PCI DSS requirement, and there may be hundreds or...

Can we edit hyperlink in Restrict editing mode in Word 2013?

hyperlink,ms-word
I am creating a form in Word 2013. I am able to restrict the text using Text form field for normal text. I also have hyperlink fields where the user needs to enter the hyperlink, and be able to click (open) the hyperlink after editing the value in the restricted...

VBA Performance: paralel or sequential analysis

performance,vba,ms-word,word-vba
I am creating a tool to help analyse revised documents. There are many checks that are performed on hundreds of files, about 10k characters in average. I have a class for each analysis, and those checks are mostly done on a sentence by sentence basis. Now, I am wondering if...

import folder of .txt files into word document

vba,ms-word,automation,word-vba
I've found a lot on importing folder of .txt files into excel, but not many on importing .txt files into word. I'm trying to get my macro to open all .txt files in a specific folder and import them into a single word document, with each .txt file having its...

VSTO document-level customization Intercept Commands

c#,ms-word,vsto
We are currently bulding a set of corporate templates using C# VSTO document-level customizations. We need to intercept the Paste command and change the content before it is pasted into the document. For example if a users is pasting an image we would also insert a caption with it, or...

How to choose a different header image in MS Word 2013 using a macro/button

vba,templates,ms-word,word-vba
I'd like to create a Word stationary template with ability to cycle through different colored logos in its header. My company uses a logo in five different colors and I would like to create a single template with a button that would allow me to cycle through the different colored...

VBA in Word code to delete or change code from ThisDocument

vba,ms-word,word-vba
I have some code in a Microsoft Word .docm file that disables the save function and pops up a message: Sub FileSave() MsgBox "Save is Disabled." & vbNewLine & "" & vbNewLine & "To save changes, use Save As." End Sub This might be tricky but what I want to...

Word - Is it possible to change easily all links' source in a document?

vba,excel-vba,ms-word,ms-office,word-vba
I have 5 Word template linked to an Excel file to automatically generate new pre-formated reports. As I am working on improving it, I have created copies that will replace the old version once I'm done. And in each template, I have approximately 70 links, so almost 350 links in...

how to know which word version is installed from my add-in (Ribbon)? with c#

c#,ms-word,add-in
I build add-in for word with c#. my add-in can work on word 2010 and 2013. how to know which word version is installed from my add-in?

How to get the range of a specific word in Word Document using Word Interop

c#,winforms,ms-word,word-interop
I am creating a C# program that inserts a table inside a word document. Now, I need to insert a table in a certain position in different word documents. All word documents/templates I have has the word <table> in it where I want to insert the table. For me to...

How to insert a HTML file as such that an object icon that links to the HTML file appears in Microsoft Word?

c#,html,ms-word,office-interop
I need to achieve the same behavior as shown above using C# code. All I have is a set of HTML files in my file system which should be added as objects to an existing Microsoft Word, so that the end user could open the HTML file(s) by clicking...

python-docx style_id error while creating a word document

python,python-2.7,ms-word
I'm following the tutorial available on python-docx site to create a MS-Word document but I'm getting an error: M:\Sites>python word.py C:\Program Files\IBM\SPSS\Statistics\22\Python\lib\site-packages\docx\styles\sty les.py:54: UserWarning: style lookup by style_id is deprecated. Use style name a s key instead. warn(msg, UserWarning) word.py from docx import Document from docx.shared import Inches import json...

VBA in Word: Programmatically add content control with a style

vba,ms-word,word-vba
When programatically adding a rich text content control to a Word .docm using VBA, is there a way to set a style for the contents? As a comparison, if I create a content control manually using the Word Developer toolbar, I can select "Use a style to format contents" in...

Need to capture current scroll position (not cursor position) in MS Word

vba,ms-word,word-vba
I need to get the current scroll position (I think that is the right term; i.e., where is my virtual lens pointed at the document, not where my cursor is) in a Word document, so that when I run a macro I can return to that position at the end....

Is using Interop the recommended method when auto-generating Office documents?

c#,ms-word,office-interop
As stated in the title, I need to do some C# coding from a Web Application that will auto-generate a Word document. So far, targeted towards Office 2007 and above users. My question would be, is using the Interop library the recommended way of doing this? Isn't there some issues...

How to construct a new Word Doc in VBA line by line without screen flashes

vba,ms-word,word-vba
The following code works to build a new Word doc line by line, but the screen flashes each time a line is inserted. I am basically generating a new document mostly comprised of a sorted list of snippets of text that I extract from an active document. I have a...

Get pages of word document

c#,.net,ms-word,interop
I'm trying to get all pages of MSWord document via Microsoft.Office.Interop.Word (I'm using C# in VS2012). What I would like to get is List< String > Pages, where index is the number of page. I understand (at least I think so) that there is no direct way to do that....

Insert tables into word via vb.net

vb.net,ms-word
I'm making an addon for word. It must be possible to insert tables. It shall be possible to specify the dimensions and location. When I insert the first table it works fine, but if I insert another table, then the first table get removed and the new one inserted. I...

Excel to word Align picture

excel,vba,excel-vba,ms-word,word-vba
I have a report that is built from Excel and outputs in Word, I also have a picture called "Picture 7". My question is once this is pasted into word from excel is there anyway to center align the picture? the picture is copied over as part of a range...

Identifying Bullets in Ms Word, using Apache POI

java,java-ee,ms-word,apache-poi
I'm trying to make an application which would read a word file (docx) and do some stuff with it. So far, I've done pretty much everything except for to identify bullets. I can find isBold(), isItalic(), isStrike() but I cannot seem to find isBullet() can anyone please tell me how...

Macro cannot acces files on the network

vba,ms-word,word-vba
I am attempting to edit some Word files in a network path, put the Macro doesn't start. If i change the path to a local path (C: or D:), it works fine. I have full access to the network path. Directory = "S:\PROJETS\GT R\test\" FType = "*.doc" ChDir Directory FName...

Unable to open word document from jenkins

windows,jenkins,ms-word
I have one windows utility which opens word document, extract data out of it and generate another word document using that data. Now my problem is that this windows exe is working fine directly on command prompt, but if I call this exe through jenkins, i.e. build step "Execute windows...

Not able to insert image after the current one in word with microsoft.office.interop.word

c#,selenium-webdriver,ms-word,office-interop
I am trying to open an existing word file and insert image into it (image name with path being passed to the function ). Code logic is working fine but challenge is every time the new image file is inserting / place on the top of the last one.mean the...

Update detail “content status” of MS Word documents with Perl / Batch / Python

python,perl,batch-file,ms-word
I am currently trying to modify the field "Content Status" that appears in the Windows Explorer in the "Details" section of a MS Word .docx file properties (i.e. Right-Click on file from Windows Explorer > Properties > Details) as shown in the screenshot below. Does anyone know how to change...

Dynamically Create Bookmarks with VBA

excel,vba,excel-vba,ms-word
I am trying to dynamically add bookmarks into a Word file from Excel based on the length of a dynamically allocated array. I then want to change the text at each bookmark to the corresponding value in the array. My reason for doing this rather than just using static bookmarks...

Dynamically create mergefields (Access to Word)

vba,ms-word
Is there anyway I can set the text of a field in Word Document using VBA from an array value? Do While .Execute Selection.MoveDown Unit:=wdLine, count:=1 Selection.Paragraphs.Indent For I = 0 To mergeFields.GetUpperBound(0) Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, PreserveFormatting:=False Selection.TypeText Text:="MERGEFIELD M_1" Selection.MoveRight Unit:=wdCharacter, count:=2 Selection.TypeParagraph Next In the place of "MERGEFIELD...

VBA for Word: Add sub on event

vba,ms-word
I want to add this code to ThisDocument in my Word .docm file. Sub AutoClose() ActiveDocument.Saved = False End Sub The code prevents the "Do you want to save?" dialog from appearing. I only want to add this however after a certain click event in the document, because I also...

Debug function altough macros disabled

vba,ms-word,word-vba
I was given a template for report (.dotm) with alot of vba code behind that gets data from a mssql database and writes the data at some bookmarks. Unfortunately, the code has an error and I have to fix it. Since I have never done vba before, I'm a bit...

Count loop and report current iteration

vba,ms-word,word-vba
So the Word macro I'm making pops up a userform where you enter a quantity x (1 of x) and it duplicates a row based on the quantity entered. The copy paste works fine, but I need to report the number of the copy based on the quantity. So for...

How can I disable Word's built-in Ribbon Tabs when a specific document is loaded?

c#,ms-word,vsto
I am using the following code right now: <?xml version="1.0" encoding="UTF-8"?> <customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <commands> <command idMso="Font" enabled="false"/> <command idMso="AlignLeft" enabled="false"/> <command idMso="AlignCenter" enabled="false"/> <command idMso="AlignRight" enabled="false"/> </commands> and so on, but this completely disables the buttons obviously. I now want to restrict my users from being able to use...

Range.Find.Execute - Forward only misbehave

c#,ms-word,word-interop
I'm using the .Net libraries for Microsoft Word 2010 interoping Word.Document doc = wb.Documents[1]; Word.Range range = doc.Range(); range.Find.Forward = true; range.Find.Execute("HELLO"); MessageBox.Show("Start " + range.Start.ToString()); MessageBox.Show("End " + range.End.ToString()); //make sure it won't even look back range.Start = range.End; range.Find.Execute("HELLO"); MessageBox.Show("Start " + range.Start.ToString()); MessageBox.Show("End " + range.End.ToString()); if...

How to reduce title to one line in MS Word using VBA

vba,ms-word,word-vba,word-2010
I am creating documents using VBA in Word with data being pulled from Excel. Unfortunately the titles are sometimes so long that they get wrapped in Word. I need the titles to remain on one line. I plan on doing this by simply changing the font size until the text...

Get access to MS Word macros from PHP

php,vba,ms-word,word-vba
The problem is following. I have a tool that generates .docm files. These files contain some macros. The code of macros has settings information, like URLs, etc. I want to somehow access from PHP this macros in order to make changes programmatically. This is especially necessary when the whole application...

how to reorder bars in excel barchart

excel,ms-word
I have a vba program which copies excel charts to word. But later only I noticed the bar positions are not in order. So how can we change the positions of bars in barchart. Hope this given below pic explains my problem. Yes, just to interchange. I tried to drag...

Class Object update using a form

forms,vba,ms-word,word-vba
I am creating a tool in VBA to create labels with information about transactions. I would like the user to use a form to give all the information and the labels will be automatically created. To do so I have created a transaction class called clsTransaction. Public PartNum As String...

Macro Removal When Submitting Documents

vba,ms-word,word-vba
I edit and format large proposals and recently started working with macros to speed up the process. However, occasionally my proposal submissions have to be electronic. I am worried the file may be rejected if there are macros attached. If I copy and paste all the text into a new...

Insert a photo to a Word bookmark from an Excel range, VBA

excel,vba,excel-vba,ms-word
I am trying to build a report generator using an excel database. I would like to insert photos into word bookmarks from an HTML link. I am wondering if it is possible to do this? Right now my code is set up to test if I can insert the photos...

MailMerge query string exceeds 255 characters

c#,ms-word,mailmerge
I'm having an issue with my automated mailmerge application. The application uses an MS Word template and an MS Word datasource. I'm using the following method to create the datasource and bind it to the template: expression.CreateDataSource(Name, PasswordDocument, WritePasswordDocument, HeaderRecord, MSQuery, SQLStatement, SQLStatement1, Connection, LinkToSource); Here is the MSDN page...

Run application.commandbars() outside excel or word

excel,vba,vbscript,ms-word
i'm trying to figure out a way to run a simple line of vba code like: application.commandbars("research").enabled = false without opening excel or word (i would like to ref this line of code both for excel and word) i was thinking of creating a word / excel object in vbs...

How to sort an array of strings containing numbers

arrays,vba,ms-word,word-vba
I'm having some trouble correctly sorting an array numerically based on strings that contain numbers: So, the sort works for all strings up until I get into 2 digit numbers. For example, if the array contains "Issue 2:" "Issue 5:" and "Issue 3:" it correctly sorts the strings to be...

output lmer summary information to word using ReporteRs

r,ms-word,lmer,reporters
I am using the package ReporteRs in R to output the results of statistical tests, and plots, to Word 2010. I'm using lmer in the lme4 package to do some analysis, and I would like to output the results of summary(foo.lmer) to Word. I wish to capture everything in the...

Akka.net actors in STA

c#,com,ms-word,sta,akka.net
I need to convert thousands of ms office documents in different formats into one common format. To get things faster i would parallelize it using akka.net for. The WordSaveAsActor should: run in Single-Threaded Appartment hold the Word Application instance make COM calls on this instance, like SaveAs(..) with paths from...

Find out background color of highlighted text in MS Word document using C# or VBA

c#,vba,ms-word,office-interop,word-vba
Following finds the highlighted text in a Word document (even if the different text at different places is highlighted with different colors). How can we find out the background color of each highlighted text. I'm using C# but VBA will also be ok: With ActiveDocument.Range.Find .Highlight = True While .Execute...

How to loop through an excel sheet from word

vba,excel-vba,ms-word
I am struggling to find out how i can loop through all rows in excel from word. What I want to achieve is that if there is something in the WP column in excel then save the active worddocument with that filename. However i cant figure out something simple as...

ms word master document deletes subdocument

ms-word
I have trouble with MS Word 2013 master document. I created a master document and added subdocuments into it. It was working normally. I saved the document and closed. When i reopened the master document, I could not see first 3 chapters. Rest of chapters were there. What is the...

How to emulate a radio button during MS Word mail merge

ms-word,mailmerge
I am trying to display the results of a survey using an MS-Word mail merge document paired with an Excel table. The survey has a radio-button question: "What is your project Status." The value in the excel table could be one of five values: {pre1, pre2, con1, con2, aban}. Without...

Uploading a word document, storing it on mysql and displaying it

php,html,mysql,ms-word
Hi I know php basics and that. I've recently rediscovered it and teaching myself new techniques. So please bear with me... In this task, I'm to upload a MS Word document via php, store it on mysql and retrieve it when needed. Is this possible? Should a file such as...

How return number of the word in text onclick or tap

c#,unity3d,ms-word,msdn
How can I return the number of the word in text onclick or tap? I was thinking of using Find.HitHighlight Method (Word) - MSDN(or something similar) but I don't how. For now I can count words in the text I have and store them in collection but how can I...

saving/recalling VBA variables in Word 2013

vba,ms-word,word-vba
I'm using VBA in Word 2013 to score and return some basic info that the end user will input in the document in some legacy form fields. My code, which works fine if I have it all in a single sub, is: Option Explicit Sub ScoreLevel() Dim a As Integer...

How to access an Office IEnumerable interface?

c#,ms-word,powerpoint,office-interop,word-interop
I am trying to write a C# add-in for PowerPoint with VS2013. But (after some years of absence in programming :) I am struggling with C#. Task is to let the user choose one installed proofing language and set it for all slides. First, it seems that PowerPoint doesn't have...

Output SQL Results into a 2 Column Table in MS Word

javascript,ms-word
I really need your help. I am designing an HTA and I would like to have the code amended below, such that I would be able to output SQL recordset results broken down in a 2 column table using MS Word. It also seems that current code inserts a blank...

Changing Whole Page Color via COM object

vbscript,ms-word
I am trying to change the whole page color in MS Word using VBScript COM interface. But the code does not seem to work. I tried the following code: Option Explicit ' Variables Dim objDoc, objFile, objWord ' Create a Word object Set objWord = CreateObject( "Word.Application" ) ' Now...

How do I specify “where” when using the insert method for build blocks in word 10

vba,ms-word,word-vba
I'm trying to add a custom building block at the click of a button in MS word 10. Below is the code currently attached to my activeX button. Private Sub CommandButton1_Click() Dim objTemplate As Template Dim objBB As BuildingBlock ' Set the template to store the building block Set objTemplate...

.NET & Word - How to Convert PlainText to MergeField in Document

c#,.net,vb.net,ms-word,mergefield
i am using Visual Studio .NET (VB) So if you have a solution in C#, just go here first (http://converter.telerik.com/) I have a document with text, and an array of words to replace: I need to replace the plaintext and substitute with actual mergefield Dim replacements(,) As String = New...

Word 2010 VBA - Nested Do Until … Loop for Search and Replaces

vba,search,replace,ms-word
I'm attempting to create a nested Do Until... Loop that will perform 15 different search and replaces in Word documents. I need to accomplish the following (semicolon at end only for listing purposes): Search space ^t; replace with ^t; Search ^t space; replace with ^t; search ^t^t; replace with ^t;...

VBA WORD How to split doc in X docs?

vba,split,ms-word,outline
I'd like to split a doc file with some Units in individual units, taking Level 1 Outlined as stop mark. Someone could help me with this? As you can see, I'm a total newbie here. Thanks a lot

copy formatted text into access using vba

ms-access,ms-word,access-vba,ms-access-2010,word-vba
I need to save formatted text from Word in an Access Database. So far I've managed to figure out how to store formatted text in an Access Field (Create a Memo Field in a Table and set the Text Format as Rich Text). Searching SO I have not yet come...

Dynamically Allocate Bookmarks in a Bullet List in Word

excel,vba,excel-vba,ms-word
I am trying to generate a bookmark on the line below a previous bookmark in a bullet list such that the word document starts as [Bookmark1] and then is transformed into [Bookmark1] [Bookmark2] Etc. so that I can adjust the formatting of the list line by line and also input...

Changing XML of docx to load images from web

xml,image,ms-word,docx
Basically, my docx size is very big and it has many images and I wanted to reduce the size of it, I tried everything, compressed the images and etc, so from 25MB I got it to 13MB. But I wanted to lower it more so I was playing around and...

Word Add-in keeps Word process alive when document is embedded via OLE

c#,com,ms-word,vsto,ole
I have built a Word Add-in which has to do a task when the user closes the document. I installed an event handler for the DocumentBeforeClose event of the Application object to do that. The problem is that the event handler appears to prevent the Word process from exiting when...

Word 2013 Mail Merge VBA “Argument not optional”

vba,ms-word,word-vba,mailmerge,word-2013
So I created a macro to allow my users to open a document select a .csv and it automatically merges the letters and opens a new document. I can open VBA and run this macro okay however, if I try adding this to the QAT as a button it gives...

embed object and display as icon in word document?

vba,ms-word,word-vba
I have a word document. In the word document I have command button. What I am after is when the user presses the command button it would open a dialog box so that the user can embed a file and display as an icon within the word document. How WOULD...

Using MS Word VBA how to Find and Replace highlighted text with the value of the highlight color

vba,ms-word,office-interop,word-vba
Suppose the following text in an MS Word 2007/2010 document, I have "testA" highlighted with blue and "testB" highlighted with green color: "This is testA and testB.". I want to programmatically replace testA with its background color index 2, and replace testB with its background color index 11. Ref: WdColorIndex...

How to manipulate a Word 2013 document opened in read only mode

c#,vba,ms-word,word-vba,readonly
I have to open Word documents for automation in read only mode. Then I have to remove some certain pages from that document, regarding some configuration the user did in the user interface of the program. Manipulation does work for footers and headers, but this particular code doesn't work. It...

Prevent typing in Word content controls

ms-word
I am working with content control fields in Word 2013. Several of the fields are dropdowns, but I noticed that users can also type something into the field. Is there a way in word to prevent users from typing into these content control fields (and only select a value from...

Deleting CommandButtons by name in VBA Word 2010

vba,ms-word,word-vba
In a word template, I have two command buttons namely [Add section] which is named "CommandButton1" [Done] - which is named "CommandButton2" I need both buttons to be deleted at the click of [Done] Here's my code so far Private Sub CommandButton2_Click() Dim i As Integer For i = ThisDocument.InlineShapes.Count...

set case of content bound via content controls in docx

ms-word,docx,docx4j
I have a docx file that contains a custom part and a web page that collects input from the user to populate that custom part. One of my "variables" is used multiple times in the document. In some cases, I need it to appear in ALL CAPS. In most cases,...

Vba word object height problems

excel,vba,object,ms-word
I have a pretty weird problem I don't understand. I have a table with a bunch of information concerning how to work with a construction project. There is an increasing amount of 'recipes' that explains specific things about the project. In the table each row is a recipe, and the...

MS Word document not visible when opening programmatically through interop

c#,ms-word,vsto,office-interop,word-interop
The following code opens the document in the background but not make it visible even though I am using Visible = true and oDoc.Activate(); using Word = Microsoft.Office.Interop.Word; Word.Application oApp = new Word.Application(); Word.Document oDoc = oApp.Documents.Open(FileName: @"C:\Folder1\Test1.docx", Visible: true); oDoc.Activate(); According to this SO post, it should have worked....

Open File dialog box to get Excel

excel,vba,ms-word,word-vba
I've written some Word VBA which takes an Excel file and updates Labels (ActiveX Control) in the Word file. The only thing is this Excel file will change path and filename each month. Instead of editing 2 variables each month, how do I add an Open File dialog box so...

DocX c# libary changing page format on InsertSectionPageBreak

c#,ms-word,docx
I am working whit DocX a library for creating Microsoft .docx files inside c#. https://docx.codeplex.com/ I am loading an preexisting file into the program and then adding content. It was the easiest way to get a pre defined header. I noticed that if i use InsertSectionPageBreak the page format of...

Android Studio: Copy text with syntax highlighting

android,android-studio,ms-word,syntax-highlighting,export-to-word
I am writing a programm with Android Studio V1.1 and I want to copy my code into a MS Word 2013 document. When I copy the code its just black in Word. Is there a way to copy the text with syntax highlighting? I copied the code into Notepad++ and...

How to convert word to image files in asp.net? [duplicate]

c#,asp.net,.net,image,ms-word
This question already has an answer here: Convert Word file pages to jpg images using C# 2 answers I have some doc or docx files.I want to convert them to images automatically if I upload doc files to server. Does anyone have solutions to solve this problem? the final...

Microsoft.Interop.Office.Word full style not applying

c#,ms-word
I am trying to produce edit a word document using Microsoft.Interop.Office.Word, and am using the Range.set_style(String style) method. I am using the method to apply a custom style that is in the document called "Req Level 1." It has a different text size, is bold, has a font, and has...

Word VBA for Search/Replace tables

vba,table,ms-word
In a Word 2010 document with 30+ tables, some with text only and the rest financial tables. I need to replace all the financial tables with a [TABLE] placeholder. How do I use VBA to select the financial tables only? I figure I could search for numbers (integers) in two...

Using VBA to manage multiple styles definitions in the same Word document

vba,ms-word,word-vba,office-2013
TL/DR: I have a game plan on how to do this below; however, I am wondering if my plan is going to prove to be too complicated, and what additional considerations I need to take into account before diving into building this project. Although I am not an experienced programmer,...

Why a file starting with ~$ is created when opening a word document?

ms-word,ms-office
We all might have noticed the creation of a file named "~$filename.docx"(hidden) when opening filename.docx using MS Word What is the purpose of this file? Why is it created and what does it contain?...

How do I change a file format when saving a Microsoft Word Doc programattically?

vba,ms-word,word-vba
Should be a pretty easy fix. I'm currently modifying a Microsoft Word doc to prompt the user to do something when they save. After they select an answer, I want to save the document as a different file type, converting it specifically from a .docm to a .docx file. Sub...

Use Office Interop on ASP.net MVC6 website

com,ms-word,office-interop,asp.net-mvc-6
I want to generate word documents from my ASP.net MVC 6 website. I've implemented several ways to generate a document in a POC : DocX, NetOffice, OpenXml, COM Interop objects. I was seduced by it. I made a Console App to test and it works. But, with ASP.net MVC6, we...

MS Word VBA for formfields

vba,ms-word,form-fields
I am trying to assign a numeric value in VBA for a dropdown formfield. I have the Msgbox just to test functionality: Sub ScreenB() Dim a As Double If ActiveDocument.FormFields("Dropdown9").DropDown.Value = No Then a = 1 Else a = 2 End If MsgBox a End Sub With this code, my...

Change default document layout when generating word document from OpenXML in C#

c#,ms-word,openxml
I've been able to generate a simple word document using a format similar to the format used in this SO question, however whenever I open the document it opens in print layout view. Is there a way that I can programmatically make it open in web layout view by default?