Document properties in Microsoft Office Word 2003 contain basic information about a document such as the file name, author, creation date, date last saved, number of words, and so forth. The purpose of document properties is to provide a common way to describe any document. Custom properties extend the role of standard properties by providing you with a way to add and populate properties with additional information about the document. You can add custom properties through the Properties dialog box or programmatically using the Add method of the CustomDocumentProperties collection. This article demonstrates both methods. Besides the text in your document, Word also maintains quite a bit of statistical and other information about your document with standard properties. You can view a portion of this information by choosing the Properties option from the File menu. Word then displays the Properties dialog box for your document, where you can use the different tabs to view the information maintained there. In addition to the standard properties maintained by Word, you can create your own custom document properties. To create a custom document property, follow these steps: • On the File menu, click Properties. ![]() ![]() Word displays the Properties dialog box for your document. • Select the Custom tab. ![]() In addition to adding and populating custom properties from the Properties dialog box, you can also do this programmatically by using the Add method of the CustomDocumentProperties collection. You can also use this same collection to set or retrieve the property values. You can access the individual by using an index value in the collection or through the name of the property. The name is the preferred method as the index changes as you add and remove properties. To add a custom property from Microsoft Visual Basic.NET, you must use automation to start Word and access the collections, properties, and methods of Word. To do so, use the following steps: To create an automation client for Word in Visual Basic.NET: • Start Visual Studio.NET. Basic tasks in Word 2010. To find and apply a template in Word, do the following: On the File tab, click New. Microsoft Visual Studio. Word Template - Fill In, Print and Preview. This tutorial is a small project to fill-in values for a Word template, save it, then have options to print the document or preview it on the WinForm. From the Project menu choose Add Reference. And find, and tick, the Microsoft Word 15.0 (or 14.0) Object Library. May 11, 2015 Getting Started with VBA in Word 2010. Macros are usually stored in a Word Macro-Enabled Template file. Click Microsoft Visual Basic for. Jan 07, 2017 In the Add Reference dialog box, set Files of type to Word Documents (*.doc; *.dot). Note In Word 2007, set Files of type to Word Documents (*.docm;*.dotm*.doc; *.dot). In the 'C: TestFiles' folder, select the Refme template. Click Open to return to the References dialog box. Click OK to return to the Visual Basic. • On the File menu, click New, and then click Project. Select Windows Application from the Visual Basic Project types. Form1 is created by default. • Add a reference to Microsoft Word Object 11.0 Library. To do this, follow these steps: • On the Project menu, click Add Reference. • On the COM tab, locate the Microsoft Word Object 11.0 Library, and then click Select. Note The Microsoft Office System includes Primary Interop Assemblies (PIAs). Microsoft Office XP does not include PIAs, but you can download them. For more information about Office XP PIAs, see the Microsoft Knowledge Base article. • Click OK in the Add References dialog box to accept your selections. If you are prompted to generate wrappers for the libraries that you selected, click Yes. • On the View menu, click Toolbox to display the Toolbox, and add a button to Form1. • Double-click Button1. The code window for the form appears. • In the code window, add the following lines to the top of the code window. Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click Dim oWord As Word.Application Dim oDoc As Word.Document Dim oBuiltInProps As Object Dim oCustomProps As Object Dim oProp As Object Dim strValue As String 'Create an instance of Word and make it visible. OWord = CreateObject('Word.Application') oWord.Visible = True 'Create a new document. ODoc = oWord.Documents.Add() 'Get the Built-in Document Properties collection. OBuiltInProps = oDoc.BuiltInDocumentProperties 'Get the value of the Author property and display it. StrValue = oBuiltInProps.Item('Author').Value MsgBox('The author of this document is ' & strValue) 'Set the value of the Subject property. 'Note that the maximum length of the property is 'is 256 characters. OBuiltInProps.Item('Subject').Value = _ 'Status Report for Human Resources' 'Get the Custom Document Properties collection. OCustomProps = oDoc.CustomDocumentProperties 'Add a property named Status Report 'and give it a value of 4th Qtr. OCustomProps.Add('Status Report ', False, _ Office.MsoDocProperties.msoPropertyTypeString, '4th Qtr') 'Display a message box to give the user a chance to verify the 'properties. MsgBox('Select Properties from the File menu ' _ & 'to view the changes.' & Chr(10) _ & 'Select the Summary tab to view ' _ & 'the Subject and the Custom tab to view the Custom ' _ & 'properties.' , MsgBoxStyle.Information, _ 'Check File Properties') 'Clean up, leaving Word running. OCustomProps = Nothing oBuiltInProps = Nothing oDoc = Nothing oWord = Nothing End Sub • Press F5 to run the application. • Click Button1 to start Microsoft Word. • When prompted, on the File menu, click Properties This code demonstrates reading and writing both the built-in document properties and the custom document properties. When run, this code displays the value of the built-in Author property, changes the Subject property value to 'Status Report for Human Resources,' and creates a custom document property named 'Status Report.' I am trying to make a template in Microsoft Word. What I want to do is turn off or on sentences and paragraphs based on whether they are applicable. I want to use the checkbox button and link that to a sentance or paragraph. When the checkbox has be chosen I want that sentance to remain in the document. When it has been left unchosen I want it to be removed from the document. I don't need the sentances / paragraphs to disappear on the page I just need them to be removed when the items is being printed - I do need there to be no gaps between selected sentances or paragraphs where unselected sentances have been left unchosen. I believe I need to write Visual Basic Code to do this. I have very limited experience with VB code. So ideally if there was some way I could get this code and just plug it in to my Word Template that would be great, otherwise some basic ground rules would be helpful on how to do this. I have Microsoft Visual Basic 6.5 with Word 2003. Maybe the Boiler.zip that you can download from the following page of fellow MVP Graham Mayor's website could be used for your purpose -- Hope this helps. Doug Robbins - Word MVP, dkr[atsymbol]mvps[dot]org Posted via the Community Bridge 'jexi007' wrote in message news:fcf68808-4fef-4b5f-a61d-ba6067ea8932@communitybridge.codeplex.com. I am trying to make a template in Microsoft Word. What I want to do is turn off or on sentences and paragraphs based on whether they are applicable. I want to use the checkbox button and link that to a sentance or paragraph. When the checkbox has be chosen I want that sentance to remain in the document. When it has been left unchosen I want it to be removed from the document. I don't need the sentances / paragraphs to disappear on the page I just need them to be removed when the items is being printed - I do need there to be no gaps between selected sentances or paragraphs where unselected sentances have been left unchosen. I believe I need to write Visual Basic Code to do this. I have very limited experience with VB code. So ideally if there was some way I could get this code and just plug it in to my Word Template that would be great, otherwise some basic ground rules would be helpful on how to do this. I have Microsoft Visual Basic 6.5 with Word 2003. Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org. Maybe the Boiler.zip that you can download from the following page of fellow MVP Graham Mayor's website could be used for your purpose -- Hope this helps. Doug Robbins - Word MVP, dkr[atsymbol]mvps[dot]org Posted via the Community Bridge 'jexi007' wrote in message news:fcf68808-4fef-4b5f-a61d-ba6067ea8932@communitybridge.codeplex.com. I am trying to make a template in Microsoft Word. What I want to do is turn off or on sentences and paragraphs based on whether they are applicable. I want to use the checkbox button and link that to a sentance or paragraph. When the checkbox has be chosen I want that sentance to remain in the document. When it has been left unchosen I want it to be removed from the document. I don't need the sentances / paragraphs to disappear on the page I just need them to be removed when the items is being printed - I do need there to be no gaps between selected sentances or paragraphs where unselected sentances have been left unchosen. I believe I need to write Visual Basic Code to do this. I have very limited experience with VB code. So ideally if there was some way I could get this code and just plug it in to my Word Template that would be great, otherwise some basic ground rules would be helpful on how to do this. I have Microsoft Visual Basic 6.5 with Word 2003. Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2018
Categories |