Menu
  • HOME
  • TAGS

Copy and Paste Hyperlink change path to absolute

hyperlink,ms-word,ms-office,copy-paste,word-2010

I Found a Workaround! Select a whole hyperlink, press shift + F2 (Copy text), place cursor on the place where you want to paste link and press ENTER (don't use paste function). And you have the same address in hyperlink :)...

Mail Merge from Multiple SQL Tables

sql-server,ms-word,mailmerge

Could you make a view on your database accessing the three tables as necessary; then in word do your mail merge against the view?

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

vba,ms-word,word-vba,office-2013

Yes, in my opinion, you are making a mistake. I have just recently finished a project where I have created a document template for a company. My experiences: Users vary in knowledge level (obviously) High level users don't like over-engineered files, because they can't use their own macros as they...

Deleting CommandButtons by name in VBA Word 2010

vba,ms-word,word-vba

The for ... next loop is done from the end (ThisDocument.InlineShapes.Count) to the start of the array to be sure to go through all items that need to be deleted. For instance, going from first to last item, if your array has 3 items: Object(1) Object(2) Object(3) By deleting the...

ms word master document deletes subdocument

ms-word

I have found my questions answer: IMPORTANT: The total size of a master document and its subdocuments cannot exceed 32 megabytes (MB). In Microsoft Windows, the maximum number of subdocuments that are allowed in a master document depends on the number of files that you have open, the size of...

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

c#,asp.net,.net,image,ms-word

use a third party component: Aspose.Words, it can do it for you. Document doc = new Document(MyDir + "Document.doc"); doc.Save(MyDir + "Document.ConvertToHtml Out.html", SaveFormat.Html); it also support save to Png format. SaveFormat.Png: Renders a page of the document and saves it as a PNG file. ...

How to loop through an excel sheet from word

vba,excel-vba,ms-word

As per our conversation in the comments, change Dim Rng1 As Range to Dim Rng1 As Object. You can find the actual values of XlDirection, Xlvalues, xlwhole enums. Preferably, it's better to do it like this: Private Const xlUp as long = -4162 'and so on Edit1: Here's an adjusted...

set case of content bound via content controls in docx

ms-word,docx,docx4j

You should be able to set the rPr property on a plain text content control to include: http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/caps.html Failing that, its not elegant, but you could always include a second element in your XML with the caps form....

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

c#,ms-word,office-interop

On the contrary, Microsoft's advice is very much not to use it: Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when...

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

c#,selenium-webdriver,ms-word,office-interop

I have modified the code with below.I am passing range object which solving my problem as of now.Still looking for better solution if there any. object o_CollapseEnd = WordC.WdCollapseDirection.wdCollapseEnd; WordC.Range imgrng = aDoc.Content; imgrng.Collapse(ref o_CollapseEnd); imgrng.InlineShapes.AddPicture(imgFilename, Type.Missing, Type.Missing,imgrng); ...

Formatting Marks also show and hides tables

excel,vba,excel-vba,ms-word

I have found the answer thanks to @Tim Williams pointing me in the right direction. It was because of the hidden text flag being set to true, I do not know how it got set to true as I can not find any reason for it to be. Anyway if...

Output SQL Results into a 2 Column Table in MS Word

javascript,ms-word

function test() { var wordApp = new ActiveXObject("Word.Application") var doc = wordApp.Documents.Add() var col doc.Tables.Add(Range=doc.Range(0, 0), numrows=1, numcolumns=2) doc.Tables(1).Borders.Enable = true row = 1 col = 0 while (!rs.eof) { col = col + 1 alert(row) if (col = 1) { doc.Tables(1).Cell(row,1).Range.Text = rs.Fields("firstname").value col = col + 1 rs.movenext...

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

hyperlink,ms-word

Ah, now your question is more clear based upon your last comment. I found this method - give it a try: http://word.mvps.org/FAQs/TblsFldsFms/HLinksInForms.htm If this works let me know, I don't have time to test it out but seems promising....

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

c#,ms-word,add-in

Assuming you're using VSTO, you can read the Globals.ThisAddIn.Application.Version property (see MSDN Blog article). string version = Globals.ThisAddIn.Application.Version; string majorStr = version.Split('.').First(); int major = Convert.ToInt32(majorStr); if (major == 14) // Word 2010 // ... else if (major == 15) // Word 2013 // ... ...

MS Word Macro to replace all hyperlinks with a single word

vba,hyperlink,ms-word,word-vba

Since you have the hyperlinks already created. It should just require looping through the documents hyperlinks collection and changing the 'TextToDisplay' property. This should get you started: Public Sub ChangeHyperlinksText() Dim hlink As Hyperlink For Each hlink In ThisDocument.Hyperlinks hlink.TextToDisplay = "Link" Next hlink End Sub ...

Dynamically create mergefields (Access to Word)

vba,ms-word

Never mind, I was able to get it to work after a bit more tweaking. Here's the final code for anyone else: Do While .Execute Selection.MoveDown Unit:=wdLine, count:=1 Selection.Paragraphs.Indent For Each fieldName In mergeFields If fieldName <> "" Then Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, PreserveFormatting:=False Selection.TypeText Text:=mergeFields(I) Selection.MoveRight Unit:=wdCharacter, count:=2 Selection.TypeParagraph I...

Word Vba Userform textbox onChange

vba,ms-word,word-vba

Do you mean : Dim myNumber If Not IsNumeric(myValue) Then myNumber = InputBox("Enter number:") MsgBox "Entered " & myNumber End If Please note that negative numbers are also Numeric....

Range.Find.Execute - Forward only misbehave

c#,ms-word,word-interop

I isolated the problem and it seem to happen only when there's special characters in the word document, particularity if text is contained inside a custom table. on normal plain documents it works fine. I ended up sampling the range.Start value after each search, if it was the same as...

How to identify a particular text box?

textbox,ms-word,word-vba,word-2013

First find out what is the name of that textbox. For that you can use this code Sub Sample() Dim shp Dim R1 As Word.Range Set R1 = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range For Each shp In R1.ShapeRange Debug.Print shp.Name Next shp End Sub Once you know the name then simply use that name...

Macro Removal When Submitting Documents

vba,ms-word,word-vba

Unless they are leaving anything in your Word document, something like "Was done via vba" or anything like that. Then creating a new Word Document with just the text copied and pasted will not copy over the macros. You could use the macros to do this as well. Just have...

Unable to open word document from jenkins

windows,jenkins,ms-word

Create an empty directory "Desktop" in C:\Windows\SysWOW64\config\systemprofile\ this solved the issue. I guess this is problem with user rights for the desktop folder under users directory. The user by which tomcat service is running....

VSTO document-level customization Intercept Commands

c#,ms-word,vsto

You may have to use repurpose commands. Here is the how to In Ribbon.xml <commands> <command idMso="Paste" onAction="CustomPaste"/> </commands> In Ribbon.cs public void CustomPaste(Office.IRibbonControl control, bool cancelDefault) { //Globals.ThisAddin.Application.Selection.Paste(); //Check if the pasted content is image and then add caption to it } ...

Excel to word Align picture

excel,vba,excel-vba,ms-word,word-vba

I believe there are two issues here. First, graphics in word have an anchor. When the graphic is pasted, the anchor for it is placed in the table created by Excel's cells. This throws off positioning. Second, I suggest using the Shape.RelativeHorizontalPosition property, which will allow your Shape.Left property to...

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

excel,vba,ms-word,word-vba

Your question is not very clear. This would likely help you anyway. If you have a String a, which you want to pad with blanks up to 255 characters, you would do Dim apad As String apad = a & space(255 - len(a)) ' or 'apad = a & String(255...

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

c#,com,ms-word,vsto,ole

Instead of attaching the DocumentBeforeClose event handler on application startup, consider attaching it on document open—and only if it's not an embedded object. The tricky part is determining whether the document being opened is an embedded object. I haven't found any documented way to explicitly check whether an Automation application...

output lmer summary information to word using ReporteRs

r,ms-word,lmer,reporters

Try to use the capture.output() function. Like this: Results <- capture.output(summary(your.lmer.model)) It stores the summary information in the new variable. After that you can use it in e.g. ReporteRs paragraph functions....

saving/recalling VBA variables in Word 2013

vba,ms-word,word-vba

There are two ways to do this, either you declare the separate subroutines e.g. sub mySub(myVar as integer) then call the sub within your code with: mySub(b) The 2nd way is to declare the variables outside any subroutines like: public b as integer then you can simply use them in...

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

vba,search,replace,ms-word

Something along these lines should at least get you started: Dim searches() As String Dim replaces() As String searches = Split("( , %", ",") replaces = Split("(,%", ",") Dim i As Integer For i = LBound(searches) To UBound(searches) With Selection.Find Do .ClearFormatting .Text = searches(i) .Replacement.Text = replaces(i) .Execute Replace:=wdReplaceAll...

how to reorder bars in excel barchart

excel,ms-word

The order of the bars is governed by the order of the source data. You can't just drag the bars around. Instead, edit the chart source data and make the desired changes. By default, the value at the top of the source data will be plotted closest to the X...

Akka.net actors in STA

c#,com,ms-word,sta,akka.net

The short answer is "yes, you can do this with Akka.NET" As Hans points out in his comment: Word doesn't care much about your library. Its interop interface is single-threaded, any call you make from a worker thread is automatically marshaled to the thread that owns the Application object. You...

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

vba,excel-vba,ms-word,ms-office,word-vba

Is it possible? Yes How? A Google search reveals multiple options with lots of code to copy/paste....

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

vba,ms-word,word-vba

Based on your error, I would suggest that you read the text file one line at a time, looping through till the EOF (End Of File). This will give you a bit more flexibility. Here is how you need to modify your LoadTextFile method to get it right, Public Function...

VBA WORD How to split doc in X docs?

vba,split,ms-word,outline

Well, I did this. It's not exactly and auto-split process but it does the thing: Sub CutSelect() Dim ruta As String Selection.Cut ruta = ActiveDocument.Path Dim doc As Document x = x + 1 Set doc = Documents.Add Selection.Paste '-----You can add some other things to do here doc.SaveAs ruta...

MailMerge query string exceeds 255 characters

c#,ms-word,mailmerge

When Word executes the OpenDataSource method, it concatenates the SQLStatement and SQLStatement1 parameter values to create a single query statement. To use a simplified example, if your query needs to be SELECT * FROM mytable Then you could for example set SQLStatement:="SELECT *", SQLStatement1:=" FROM mytable" i.e. you need to...

VBA Performance: paralel or sequential analysis

performance,vba,ms-word,word-vba

I consider this pretty much a no-brainer - do as large of a chunk as you can hold in memory at the same time. Most of the performance issues in Word come from resolving Ranges and Selections. Paragraphs, Sentences, and Words are even worse because Word has to pre-parse the...

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

vba,ms-word,word-vba

Ok, I solved the problem with the following code, posting it for others who might drop by in the future. Private Sub CommandButton1_Click() Dim objTemplate As Template Dim objBB As BuildingBlock ' Set the template to store the building block Set objTemplate = ActiveDocument.AttachedTemplate ' Access the building block through...

Regular Expression in Word VBA

regex,vba,ms-word

Character classes ([]) match literally any of the contained characters. Because of that, [First|Second|Third|1|2|3] matches F, i, r, s, t, |, S, etc. You'll want to use alternation outside of the character class. You can group this using (...) or if you want a non-capturing group (?:...). Try replacing [First|Second|Third|1|2|3]...

python-docx style_id error while creating a word document

python,python-2.7,ms-word

Simple but hard to debug. Just add space between words in style. document.add_paragraph('Intense quote', style='IntenseQuote') Changes to: document.add_paragraph('Intense quote', style='Intense Quote') ...

Get access to MS Word macros from PHP

php,vba,ms-word,word-vba

A .docm document can be more or less be considered to be a normal .zip file. You can therefore open your document with some PHP unzipping function/library, thereby gaining access to the included file word/vbaProject.bin. You then need find or create a PHP library that can modify this vbaProject.bin file....

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

c#,visual-studio,crystal-reports,ms-word,converter

I have done this in the past by creating a text box on the report canvas. Copy and paste the contents of your Word Doc into the text box. Maybe 1 text box per Word Doc page as I am not sure if there is a text limit in a...

Debug function altough macros disabled

vba,ms-word,word-vba

How can anyone expect the code in the template to work if macros are disabled? Try ALT+F11 to get into the VBA environment and show the code. Put the cursor in the code you want to debug and press F8 to step into it or F5 to run it to...

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

python,perl,batch-file,ms-word

Thanks to 'Haf Linger', I managed to found the answer to my problem: #!perl use strict; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); ##CONFIG## my $new_status="Closed"; my $docx_name="TEST.docx"; my $tmp_name="tmp.docx"; my $replace_file=1; #set to 0 for testing purpose #### #Open docx file my $doc = Archive::Zip->new($docx_name); #Retrieve old status my $old_status=undef;...

import folder of .txt files into word document

vba,ms-word,automation,word-vba

here is something to get you started Word 2010 Edit this should allow you to open all txt files in one document and save it Option Explicit Sub AllFilesInFolder() Dim myFolder As String Dim myFile As String Dim wdDoc As Document Dim txtFiles As Document Application.ScreenUpdating = False myFolder =...

Class Object update using a form

forms,vba,ms-word,word-vba

The problem seems to be in the scope of your declaration. By doing this: Private Sub UserForm_Initialize() (...) Dim trans As New clsTransaction '<-- declaration + assignment End Sub you are declaring trans in the scope of UserForm_Initialize(). Hence, when you then try to do something with it into another...

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

Try this: Sub ReplaceHighlightedTextColor() Dim rng As Range Set rng = Selection.Range With rng.Find .ClearFormatting .Highlight = True While .Execute(Forward:=True, Format:=True) 'Note: 'rng' is now the range containing the matched content rng.Text = rng.FormattedText.HighlightColorIndex Wend End With End Sub ...

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

vba,ms-word,word-vba

Don't use file extension to indicate file type. Don't use a fixed number of chars to remove an extension - this will fail for old fashioned .doc (instead of .docm). Use InStrRev. This is designed for things like this. Strip the extension off, then save as your desired type using...

Extracting data from Excel to Access Database

database,excel,ms-access,ms-word

Translate that form into Excel. Use "Collect Data" under the "External Data" tab on the ribbon to collect data from customers. To pull data onto your spreadsheet from Access do something like this. Use an Excel spreadsheet for the form. Then make a command button with the following event on...

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

vba,ms-word,ms-office,word-vba

EDIT SOLUTION FOUND For posterity ... This code finds all paragraphs with less than 100 characters (assumes a heading) and underlines them: Sub Underline_Header() Dim numOfParagraphs As Integer numOfParagraphs = ActiveDocument.BuiltInDocumentProperties("NUMBER OF PARAGRAPHS") Selection.HomeKey Unit:=wdStory For x1 = 1 To numOfParagraphs Selection.Paragraphs(1).Range.Select char_count = Len(Selection.Paragraphs(1).Range) If char_count < 100...

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

php,html,mysql,ms-word

There are a few topic to be discussed here. The form To upload the file, change the form enctype attribute. <form action="insert.php" method="post" enctype="multipart/form-data"> : </form> Storing the file You could store the file in a database, or just as file in the server disk system. Whatever you choose, it...

How return number of the word in text onclick or tap

c#,unity3d,ms-word,msdn

What you should do is use a dictionary where each word is the key value. public Dictionary<string, int> AnalyzeString(string str) { Dictionary<string,int> contents = Dictionary<string,int>(); string[] words = str.Split(' '); foreach(string word in words) { if(contents.ContainsKey(word)) { contents[word]+=1; } else { contents.Add(word,1); } } return contents; } With this you...

Apply a TableStyle to a Word Table

c#,ms-word,openxml,docx

Finally figured it out. I was using the style name and not the style id. So the line where the style is declared should look like: TableStyle tableStyle = new TableStyle { Val = "LightShading-Accent1" }; ...

VBA in Word: Programmatically add content control with a style

vba,ms-word,word-vba

If you already created the style, you can just assign it like this: oCC.DefaultTextStyle = "style_name" Now, if not, you'll have to add your style first. Something like: ActiveDocument.Styles.Add Name:="MyStyle1", Type:=wdStyleTypeCharacter With ActiveDocument.Styles("MyStyle1").Font .Name = "Arial" .Size = 12 .Bold = True .Color = RGB(255, 0, 0) 'you can use...

How to sort an array of strings containing numbers

arrays,vba,ms-word,word-vba

Strings are sorted by their characters so strings "10", "1" and "8" will be sorted differently then numbers 10,1 and 8. Just strip the array of the string "Issue:" and convert the values in the array before comparing them to Longs using the CLng function like this: CLng(arr(i)). Your code...

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

c#,vba,ms-word,office-interop,word-vba

The below statement would get you the color index of selected text in MS Word Dim objSelection As Selection Set objSelection = Application.Selection Msgbox objSelection.FormattedText.HighlightColorIndex The value returned is one of wdColorIndex enumeration. List of values in enumeration can be seen here https://msdn.microsoft.com/en-us/library/bb237561(v=office.12).aspx Update#1 Below code is using ActiveDocument.Range.Find as...

Vba Ms-Word Nested Error Control

vba,error-handling,ms-word

On Error GoTo [error-handler-label] tells VBA to jump to the specified label whenever a runtime error occurs in a method. When you use error handlers, you're telling VBA "it's all good, no need to blow everything up, I can handle it". So when Sub D runs: Sub D() On Error...

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

excel,vba,excel-vba,ms-word

That is because your code is slightly incorrect. Also imagePath is a variable. When you put it within Quotes, it becomes a string. Since I don't have access to the picture link mentioned in your post, I am using a different link. Try this (In MS Word) Sub photobomb() Dim...

Microsoft.Interop.Office.Word full style not applying

c#,ms-word

Create your Req Level 1 style Style based on (no style) Create Req Level 2 style Style based on Req Level 1 Click on Multilevel list Define a new list style Click on Format Numbering Click on the more button Link level to Req Level 1 Click on level 2...

DocX c# libary changing page format on InsertSectionPageBreak

c#,ms-word,docx

I found solution! For me it works with the following code: Novacode.Paragraph p = docx.InsertParagraph(someText, false, someFormat); p.InsertPageBreakAfterSelf(); or just add empty paragraph: Novacode.Paragraph p = docx.InsertParagraph(string.Empty, false); p.InsertPageBreakAfterSelf(); Thus if we insert page without inserting section it will no break the format!...

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

c#,ms-word,vsto

You are on the right avenue. You need to use callbacks instead of attributes. But Office caches the values and don't call the callbacks each time as you want it. Instead, to refresh the UI (force Office application to invoke callbacks) you need to use the Invalidate or InvalidateControl methods...

Dynamically Allocate Bookmarks in a Bullet List in Word

excel,vba,excel-vba,ms-word

2 issues: First, wrdRange is only set the first time through the loop, and can't change after that due to the If Count <> 1 test. Check all of the references to wrdRange for If Count <> 1. Second, when you are setting newRange = prevRange, you aren't getting a...

Changing XML of docx to load images from web

xml,image,ms-word,docx

Found the answer from here: http://blogs.msdn.com/b/dmahugh/archive/2006/12/10/images-in-open-xml-documents.aspx Needed to add a param: TargetMode="External" ...

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

c#,ms-word,openxml

Yes, you can by using a OpenXML.WordProcessing.View. You need to create a View with its Val set to ViewValues.Web. Then you need to create a Settings object and append the view to it. Finally, you need to create a DocumentSettingsPart and set its Settings property to the settings object you've...

Macro cannot acces files on the network

vba,ms-word,word-vba

If you are using the Dir function, there is no need to change directory first. Try this Directory = "S:\PROJETS\GT R\test\" FType = "*.doc" FName = Dir(Directory & FType) Documents.Open FileName:=Directory & FName ...

How to emulate a radio button during MS Word mail merge

ms-word,mailmerge

I don't know why you can't combine it as you have, but ... Maybe I'm missing something, but when you are typing out the mergefield statement, where you currently have "Check!", just replace it with the symbol you want directly (i.e., put your cursor there, then on the 'insert' tab,...

Count loop and report current iteration

vba,ms-word,word-vba

I think you're problem is in the fact that you're iterating i inside your for loop which already iterates on i If Label2.TextBox3.value is 4 then your loop would only run 3 times because of your i = i + 1 line. I don't totally follow your logic but try...

Vba word object height problems

excel,vba,object,ms-word

I haven't had a chance to test this, but it should parse your "recipe" into multiple cells, starting at C3. I'm assuming that these are written as sentences, so I'm finding the last period within 1024 characters, and putting everything up to that in the first cell, then continuing from...

Insert tables into word via vb.net

vb.net,ms-word

Assuming you're using the code above for adding both tables (possibly in a loop) I think the issue is that you're overwriting the first table with the second one since you use the same range. The documentation for Tables.Add says: The range where you want the table to appear. The...

Dynamically Create Bookmarks with VBA

excel,vba,excel-vba,ms-word

You should be able to use the SetRange method as per below: Set prevRange = wrdDoc.Bookmarks(PrevBmarkName).Range Set newRange = prevRange 'Have to set the range to something initially newRange.SetRange prevRange.End, prevRange.End ActiveDocument.Bookmarks.Add "BmarkName", newRange ...

VBA for Word: Add sub on event

vba,ms-word

Programatic access to the VBA project will need to be enabled if it isn't already. However, to add the sub you described after the other code runs add this code to your sub: ThisDocument.VBProject.VBComponents("ThisDocument").CodeModule.AddFromString "Sub AutoClose(): ActiveDocument.Saved = False: End Sub" That should do the trick. You may have to...

Insert and activate a phone number in a generated word document

c++,vba,ms-word,ms-office

Maybe the following code would be helpful to you? ThisWorkbook.ActiveSheet.Hyperlinks.Add Range("A1"), "http://stackoverflow.com" Just instead of the web address you would need the phone number....

How to access an Office IEnumerable interface?

c#,ms-word,powerpoint,office-interop,word-interop

You should use the Languages property to get the collection of languages. _Application.Languages Property Returns a Languages collection that represents the proofing languages listed in the Language dialog box. Here _Application represents the Microsoft Office Word application....

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

vba,ms-word,word-vba,word-2010

This page says you should shrink your Range so it excludes the end-of-cell marker. Dim newRange As Range With tblTitle.cell(2, 1) .Range.Text = rStatTitle.Cells(1, 1) Set newRange = .Range newRange.End = newRange.End -1 Do Until newRange.ComputeStatistics(wdStatisticLines) <= 1 ...

Word VBA for Search/Replace tables

vba,table,ms-word

Something like this: Sub ReplaceTables() Dim oTable As Table Dim oRng As Range For Each oTable In ThisDocument.Tables If oTable.Rows.Count > 1 And oTable.Columns.Count > 1 Then If IsNumeric(oTable.Cell(2, 1).Range.Words(1).Text) And _ IsNumeric(oTable.Cell(2, 2).Range.Words(1).Text) Then Set oRng = oTable.Range oTable.Delete oRng.Text = "[TABLE]" & vbCrLf End If End If Next...

embed object and display as icon in word document?

vba,ms-word,word-vba

Okay here is start Option Explicit Sub AddFileIcon() SendKeys "%F{TAB 4} {TAB 5}" Dialogs(wdDialogInsertObject).Show End Sub Now you Create Button :-) and call the Macro Here is help full Links VBA SendKeys Word Dialog Boxes ...

VBA in Word code to delete or change code from ThisDocument

vba,ms-word,word-vba

A simpler way would be to have a variable of type Boolean. When the button is clicked change the value of the Boolean, and then use a conditional statement to re-enable saving

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

ms-word,ms-office

It maintains temporary information about the current state of the document. Have you ever encountered a crash and when you open Word it asks you to recover certain documents that were being edited? That's where it gets that information....

MS Word VBA for formfields

vba,ms-word,form-fields

You should use FormFields.Result Sub ScreenB() Dim a As Double If ActiveDocument.FormFields("Dropdown9").Result = "No" Then a = 1 Else a = 2 End If MsgBox a End Sub ...

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

vba,templates,ms-word,word-vba

As mentioned, there are several ways to do this. I would suggest storing the images outside of the template, otherwise all documents based on the templates would include all logo images, even if they are not shown, making the documents bigger than they need to be. That approach makes installing...

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

The macro recorder is your friend. Instead of InsertFile, use InlineShapes.AddOLEObject instead. See https://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.inlineshapes.addoleobject%28v=office.11%29.aspx. I just recorded embedding a Word object and this is what I got: Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.12", _ FileName:=[pathToMyFile], LinkToFile:= _ False, DisplayAsIcon:=True, IconFileName:= _ "C:\PROGRA~2\MICROS~1\Office14\WINWORD.EXE", IconIndex:=1, IconLabel:= _ [myFileName] ...

Microsoft Word 2010 VBA: Using regex to find and replace

regex,replace,ms-word,word-vba,pci

Since it seems like you are using the Word wildcard syntax, you probably can use <, which asserts beginning of word, and >, which asserts end of word to prevent the pattern from matching when the text is preceded or succeeded by letters or numbers (which is how it seems...

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

c#,vba,ms-word,word-vba,readonly

In order to turn off ReadingMode your need to put this at the beginning of your code Globals.ThisAddIn.Application.Options.AllowReadingMode = false; You may get errors because of the direction of your loop. Your first page is page 1 once you delete this then page 2 becomes page 1 etc If you...

How to Expose Listbox in UserControl in CustomTaskPane VSTO C#

c#,ms-word,vsto

It appears my foreach (and hence my cast) was not correct (per Eugene Astafiev's question in the comment above). I found this SO Post that suggesting looping with type Control instead of UserControl. I did this and all was good. Here is the code: foreach (Control lbxControl in myUserControl.Controls) {...

How to insert custom page number in Aspose.Words

c#,c#-4.0,ms-word,aspose.words

You can get idea from this page in Aspose documentation. Below is the sample code taken from the same page, but only related to custom page numbers. String src = dataDir + "Page numbers.docx"; String dst = dataDir + "Page numbers_out.docx"; // Create a new document or load from disk...

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

c#,winforms,ms-word,word-interop

You can use the Find object of an empty (or indeed any) Range to set the bounds of the range to a particular word/string in the document: Word.Range range = document.Range(0, 0); if (range.Find.Execute("<table>")) { // range is now set to bounds of the word "<table>" } The Execute method...

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

pdf,ms-word

We can do it in PowerShell. Break your requirement in two pieces FIRST - Convert PDF to WORD Document '**** The script runs in a loop until it detects a new file in the directory '**** It checks the source folder every 30 seconds. To change this interval '**** change...

Use Office Interop on ASP.net MVC6 website

com,ms-word,office-interop,asp.net-mvc-6

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment. If you are building a solution...

Run application.commandbars() outside excel or word

excel,vba,vbscript,ms-word

You should be able to get an existing instance of the application in vbscript code like so: Dim excelObj Set excelObj = GetObject(, "Excel.Application") You can then call any application methods on that object: excelObj.CommandBars("research").Enabled = False For Word, do the same as above but use "Word.Application". Note: GetObject will...

copy formatted text into access using vba

ms-access,ms-word,access-vba,ms-access-2010,word-vba

Here's a method that heavily references this. Before you start make sure you have these (or your Access version's equivalent) references ticked in VBA editor > Tools > References: Microsoft Word 15.0 Object Library Microsoft Office 15.0 Object Library Assuming you've set up a form with a command button to...

Get pages of word document

c#,.net,ms-word,interop

Eventually, I finished up with this, and it works (it's lame, it's ugly, but it does what it should): public string[] GetPagesDoc(object Path) { List<string> Pages = new List<string>(); // Get application object Microsoft.Office.Interop.Word.Application WordApplication = new Microsoft.Office.Interop.Word.Application(); // Get document object object Miss = System.Reflection.Missing.Value; object ReadOnly = false;...

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

vba,ms-word,word-vba

Pupa Rebbe's solution of adding Application.ScreenUpdating = False before the "For" loop works, thanks! A cursor flashes a little bit as it is working, but it's nothing like the annoying strobe effect I was getting. ...

XML to Word using custom paragraph styles and XSLT

xml,xslt,ms-word

I've looked at OpenXML with Office. The tags are pretty easy to use, but I don't like the whole ZIP archive solution. This means styles go in one XML file, content in another, etc. Then you'll want to check out The Flat OPC Format, where the OPC parts are...

Android Studio: Copy text with syntax highlighting

android,android-studio,ms-word,syntax-highlighting,export-to-word

As long as MS Word 2013 does not support syntax highlighting for code, you are not able to "automatically" colorize the copied code. Since the plain text does not contain color information's. It's only text. The highlighting comes from Studio itself, which parses the text and colorizes the text accordingly...

Changing Whole Page Color via COM object

vbscript,ms-word

When setting the background color programmatically it's displayed only if you change the view type to Online Layout: objDoc.Background.Fill.Visible = True objDoc.Background.Fill.ForeColor.RGB = RGB(55, 255, 155) objDoc.Background.Fill.Solid objWord.ActiveWindow.View.Type = 6 It'll be visible only in that layout, though, so this might be a bug. On a more general note: please...