![]() ![]() When I do this, I use the Add method and I specify the Range that will host the table (the range I have stored in the $Range variable), the number of rows, and the number of columns that the table will contain. Now that I have a Range object, I can add a table to the Tables collection. $Word = New-Object -comobject word.application I then obtain a range object from the document and store the returned objects in the appropriate objects. I create the Word.Application object, set it to not be visible, and add a document to the Documents collection object. $Number_Of_Columns = ($topics | gm -MemberType NoteProperty).count $topics = Import-Csv C:\Lit\Shakespeare.txt ![]() I find the number of rows that I will need by counting the number of rows in my CSV file. Each column will be added as a NoteProperty, so I use the Get-Member cmdlet to find the NoteProperty members, and I count them. I want to know how many columns I have in my CSV file. I include this when I create the WdSaveFormat type. Because I am going to use the SaveAs method from the Document object, I know that I will need to pass the format by reference. Now I open the Windows PowerShell ISE, start a new script, and set my initial variables. So all I need to do is to add the literary approach as a third column to the CSV file. I did that yesterday in Add Custom Headers to Folder Full of Word Documents. Getting startedīut what do I have? I already have a text file with my plays, and I already came up with a listing of topic ideas for each of the plays. ![]() That is like, I don’t know, maybe a dozen steps. I then have to save the file, open email, find the file, and send the email. So what is the big deal? I would have to create a table, type out each of the plays, add my topics, and add my critical approach to each topic. Here is the scenario: I need to supply my professor in my Shakespeare class with a list of proposed topics and my critical approach to them. Today’s script is one of those things that rates pretty high on my annoyance meter. I use what I call the “annoyance meter” quite often to determine whether to write a script or not. One of the cool things I like to do with Windows PowerShell is to combine multiple tasks so that it makes life easier for me. Microsoft Scripting Guy, Ed Wilson, is here. ![]() Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to create a document in Microsoft Word, add a table, and email the document as an attachment. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |