evotecit / pswriteword Goto Github PK
View Code? Open in Web Editor NEWPSWriteWord is powershell module to create Microsoft Word documents without Microsoft Word installed...
License: MIT License
PSWriteWord is powershell module to create Microsoft Word documents without Microsoft Word installed...
License: MIT License
Hello @EvotecIT,
first of all, thanks for your great PowerShell Module. :-)
I have a question. When I use Add-WordTable iwith parameter -Transpose and I submit a datatable, the module or what ever order the first column alphabetically not like in the datatable.
When I use the function without -Transpose it is working fine.
Does anyone know to solve this?
Thanks
Arne
Hi there,
First time trying to use your module and test some basic functionality. I was expecting that using
Get-WordDocument -filepath .\test.docx
would return an object containing details about the file, but actual behaviour seems to just exit the console.
Powershell 5.1
Windows 10 Pro vers 10.0.19042 (Build 19042)
Add function ConvertTo-PDF
do yo have an example for using the Add-WordTabStopPosition and set the text position to the next TabStop?
When creating a table using -Transpose it defaults to the "Name, Value" title of the two columns, The -OverwriteTitle only allows to set a single title across the entire table, it would be really useful to be able to set the title of each column so it isnt just Name and Value.
In the "Example-AddCustomProperty.ps1" example, a DocProperty field is added to the document. This example then continues to obtain all the document properties and add them as text to the document.
Is there a way to add a document property to the document as a field that is automatically updated if the document property is changed?
Essentially looking for the same functionality as "Insert Field" that is provided by Word.
Hello,
Under Add-WordTable -Design parameter has option "Custom", Is there an example on how to use the -Design Custom ?
Add-WordTable -WordDocument $WordDocument -DataTable $DataTable -Design Custom
Also if using Custom is possible, how do i define the Custom design?
Hi All,
Kindly guide me how to specify the row height or Truncated Texts in word table.
in issue in i am creating one word file with table the data in the table cell is very long which is causing me inconsistency in my table and document formatting.
Error trying to load module on Windows 7 machine with PS version 4.0
PS U:\> import-module PSWriteWord
enum : The term 'enum' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At C:\Program Files\WindowsPowerShell\Modules\PSWriteWord\Enums\LineType.ps1:1 char:1
+ enum LineType {
+ ~~~~
+ CategoryInfo : ObjectNotFound: (enum:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS U:\> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
4 0 -1 -1
When adding a table, I would like to be able to specify the Font-Size for all the content in the table, similar to how I can use the " -FontSize " parameter when adding Paragraphs.
(I don't seem to be able to tag this with the "request" label, so I put it in the title)
For security reasons, can you support password protection for document?
I found that the add-wordprotection function only protects document replication
Thank you very much for this great module!
When I call Add-WordParagraph or Add-WordPageBreak, fx in your example: Example-CreateWord1.ps1, I get this error:
Unable to find type [InsertWhere].
At C:\Temp\PSWriteWord-Master\Public\PSWordParagraphOther.ps1:72 char:26
+ [alias('Insert')][InsertWhere] $InsertWhere = [InsertWhere]:: ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (InsertWhere:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
What do I do wrong?
Best regards
Kim B. Christensen
Hi,
Is it possible to write to Word's built-in properties (e.g. Title, Author, Tags) using this module?
Whether this function can be implemented?
This works - new document
Import-Module PSWriteWord -Force
$FilePath = "$Env:USERPROFILE\Desktop\PSWriteWord-Example-TableOfContent3.docx"
$WordDocument = New-WordDocument -FilePath $FilePath
$Toc = Add-WordTOC -WordDocument $WordDocument -Title 'Table of content' -HeaderStyle Heading2
Add-WordSection -WordDocument $WordDocument -PageBreak
Add-WordText -WordDocument $WordDocument -Text 'This is my first title' -HeadingType Heading1
Add-WordSection -WordDocument $WordDocument -PageBreak
Add-WordText -WordDocument $WordDocument -Text 'This is my second title' -HeadingType Heading1 -Color Red -CapsStyle caps
Add-WordSection -WordDocument $WordDocument -PageBreak
Add-WordText -WordDocument $WordDocument -Text 'This is my third title' -HeadingType Heading2 -Italic $true -Bold $true
Save-WordDocument $WordDocument
### Start Word with file
Invoke-Item $FilePath
This doesn't work - Load document
Import-Module PSWriteWord -Force
$FilePath = "$Env:USERPROFILE\Desktop\PSWriteWord-Example-TableOfContent7.docx"
$FilePathTemplate = "$PSScriptRoot\Templates\WordTemplate.docx"
$WordDocument = Get-WordDocument -FilePath $FilePathTemplate
$Toc = Add-WordTOC -WordDocument $WordDocument -Title 'Table of content' -HeaderStyle Heading2
Add-WordSection -WordDocument $WordDocument -PageBreak
Add-WordText -WordDocument $WordDocument -Text 'This is my first title' -HeadingType Heading1
Add-WordSection -WordDocument $WordDocument -PageBreak
Add-WordText -WordDocument $WordDocument -Text 'This is my second title' -HeadingType Heading1 -Color Red -CapsStyle caps
Add-WordSection -WordDocument $WordDocument -PageBreak
Add-WordText -WordDocument $WordDocument -Text 'This is my third title' -HeadingType Heading2 -Italic $true -Bold $true
$WordDocument.Xml
Save-WordDocument $WordDocument -FilePath $FilePath
### Start Word with file
Invoke-Item $FilePath
This issue was reported by me - xceedsoftware/DocX#245
Is support for styles on the roadmap?
I'm still receiving "Unable to find type [InsertBeforeOrAfter]" using the latest version of PSWinDocumentation.AD and Documentimo:
C:\Users***\Documents\WindowsPowerShell\Modules\PSWriteWord\1.0.2\PSWriteWord.psm1:820 char:9
~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
Tried to replace Xceed.Words.NET.dll v1.3.0 with v1.2.0 but the error still exsists.
Any ideas? :)
I cannot seem to get the contents of a HashTable to be displayed in a Table.
What I expect: A table with 1 column for my keys, and 1 column for my values
What actually happens: A table with no values in it. Only the first line has the values "Name" and "Value".
(As an aside, I found that an array of System.Object can be displayed in a table, but I honestly would rather avoid that as the syntax is far too verbose for my liking)
Code to demonstrate this:
$hash = @{}
$hash.add("HQ-1", "5.54.546")
$hash.add("EUR-1", "6.0.0.1")
$hash.add("HQ-2", "5.6")
$hash.add("EUR-2", "6.1.5")
$hash.add("EUR-3", "6.2")
$obj = New-Object System.Object
$obj | Add-Member -type NoteProperty -name Name -Value "Ryan_PC"
$obj | Add-Member -type NoteProperty -name Manufacturer -Value "Dell"
$obj | Add-Member -type NoteProperty -name ProcessorSpeed -Value "3 Ghz"
$obj | Add-Member -type NoteProperty -name Memory -Value "6 GB"
$myObject2 = New-Object System.Object
$myObject2 | Add-Member -type NoteProperty -name Name -Value "Doug_PC"
$myObject2 | Add-Member -type NoteProperty -name Manufacturer -Value "HP"
$myObject2 | Add-Member -type NoteProperty -name ProcessorSpeed -Value "2.6 Ghz"
$myObject2 | Add-Member -type NoteProperty -name Memory -Value "4 GB"
$myObject3 = New-Object System.Object
$myObject3 | Add-Member -type NoteProperty -name Name -Value "Julie_PC"
$myObject3 | Add-Member -type NoteProperty -name Manufacturer -Value "Compaq"
$myObject3 | Add-Member -type NoteProperty -name ProcessorSpeed -Value "2.0 Ghz"
$myObject3 | Add-Member -type NoteProperty -name Memory -Value "2.5 GB"
$myArray = @($obj, $myobject2, $myObject3)
Import-Module PSWriteWord #-Force
$FilePath = "L:\RICHIE\Desktop\2\PSWriteWord-x.docx"
$WordDocument = New-WordDocument $FilePath
Add-WordTable -WordDocument $WordDocument -Table $hash -Design 'ColorfulList' #-Verbose
Add-WordTable -WordDocument $WordDocument -Table $myArray -Design 'ColorfulList' #-Verbose
Save-WordDocument $WordDocument
Invoke-Item $FilePath
Thanks for your great script aggain!
So I would love to have a feature to covert all Fields of a Document to text:
CTRL+SHIFT+F9 or macro work around -> works
https://docs.microsoft.com/en-us/office/vba/api/word.fields.unlink
With ActiveDocument.Sections(1).Range.Fields
.Update
.Unlink
End With
I could not find any way to unlink fields with PSWrite word. I also tried to check the dll "DocX from Xceed Software" but I did not find a "unlink" functionality. I thought maybe another feature/method may be used to convert the fields to their text values but did not find any alternative solution yet.
Hello,
I am new to GitHub and I am looking for instruction on how to import info into a word template without office installed on the server.
I have a templete.docx with bookmarks created.
Code example:
function ipaddr
{
param([string]$CompName)
$wmi = Get-WmiObject -Query "SELECT * from Win32_NetworkAdapterConfiguration WHERE IPEnabled='true'" -ComputerName $Computers #-Credential $cred
foreach ($nic in $wmi)
{
$nic.IPAddress
}
}
function osver
{
param([string]$CompName)
$osver = Get-WmiObject -Query "SELECT Caption from Win32_OperatingSystem" -ComputerName $Computers #-Credential $cred
$osver.Caption
}
function domain
{
#param([string]$CompName)
$domain = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()
$domain.DomainName
}
function Processor
{
$ProcSpecs = Get-CimInstance CIM_Processor
$ProcSpecs.Name
}
function ram
{
$ram = Get-WMIObject -class win32_physicalmemory |Measure-Object -Property capacity -Sum | % {[Math]::Round(($_.sum / 1GB),2)}
$ram
}
function latency
{
$latency = Get-Counter -Counter "\LogicalDisk(*)\Avg. Disk Queue Length"
$latency.CounterSamples
}
function sql
{
$Output = $maxMem
$maxMem = Invoke-Sqlcmd -Query "SELECT name, value
FROM sys.configurations
WHERE name like '%max server memory%'
ORDER BY name OPTION (RECOMPILE)" | select -ExpandProperty value
"Max SQL Memory= " + $Output
}
# specify fill path to the word doc where bookmarks are defined.
$docTemplate = "C:\Powershell\template.docx"
if (! (test-path $docTemplate))
{
throw "$($docTemplate) is not a valid path"
}
$computers = $env:COMPUTERNAME
$msWord = New-Object -Com Word.Application
$wordDoc = $msWord.Documents.Open($docTemplate)
$wordDoc.Activate()
#defines IP address input
$objRange = $wordDoc.Bookmarks.Item("ip").Range
$objRange.Text = ipaddr
$wordDoc.Bookmarks.Add("ip",$objRange)
#defines OS version input
$objRange = $wordDoc.Bookmarks.Item("osversion").Range
$objRange.Text = osver -CompName $computer
$wordDoc.Bookmarks.Add("osversion",$objRange)
#defines hostname input (from the $computer value above)
$objRange = $wordDoc.Bookmarks.Item("hostname").Range
$objRange.Text = $computer
$wordDoc.Bookmarks.Add("hostname",$objRange)
#defines Domain input
$objRange = $wordDoc.Bookmarks.Item("domain").Range
$objRange.Text = domain -CompName $domain
$wordDoc.Bookmarks.Add("domain",$objRange)
#defines Processor Specs
$objRange = $wordDoc.Bookmarks.Item("Processor").Range
$objRange.Text = processor -CompName $ProcSpecs
$wordDoc.Bookmarks.Add("processor",$objRange)
#defines ram
$objRange = $wordDoc.Bookmarks.Item("ram").Range
$objRange.Text = ram -CompName $ram
$wordDoc.Bookmarks.Add("ram",$objRange)
#defines latency
$objRange = $wordDoc.Bookmarks.Item("ram").Range
$objRange.Text = latency -CompName $latency
$wordDoc.Bookmarks.Add("latency",$objRange)
#defines ram
$objRange = $wordDoc.Bookmarks.Item("ram").Range
$objRange.Text = ram -CompName $ram
$wordDoc.Bookmarks.Add("ram",$objRange)
# Save the document to disk and close it. CHange $filename path to suit your environment.
$filename = "C:\Powershell\" + $computer + ".docx"
$wordDoc.SaveAs([REF]$filename)
$wordDoc.Close()
Still working through some bugs, but basically works with word installed.
Thanks,
-Jeff
The following code generates a Warning that the file does not exist and an error failing to open the document. The document does exist at that path ($File below is from a Get-ChildItem result). If the []'s are removed from the filename then Get-WordDocument loads the file as expected with no other changes.
$Doc = Get-WordDocument -FilePath $File.FullName -Verbose -ErrorAction Stop
Errors/Warnings
WARNING: Get-WordDocument - Document doesn't exists in path C:\Users\kevin\Documents\FyrsoftAccel\FyrSoftAccelerators\Documentation\Input\[Customer Name] - SCOM SAC Infrastructure Design 3.5.docx. Terminating loading word from file.
1/9/2019 10:38:51 ERROR Failed to open Document C:\Users\kevin\Documents\FyrsoftAccel\FyrSoftAccelerators\Documentation\Input\[Customer Name] - SCOM SAC Infrastructure Design 3.5.docx
So DocX 1.6 was released: xceedsoftware/DocX@a758737
It means it supports Net Standard now and PSWSriteWord can be updated as well. The difference is in licensing. MSPL changes to Community License which is non-commercial.
[40] # New-WordDocument -FilePath c:\temp\mydoc
format-default : Object reference not set to an instance of an object.
+ CategoryInfo : NotSpecified: (:) [format-default], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.FormatDefaultCommand
Fresh install from PowerShell Gallery with Install-Module PsWriteWord
Hello, I posted about this a few months ago and forgot about this #40.
I am trying to write to the "Title" property of a word document. When I use the Add-WordCustomProperty, a new custom property called "Title" is added, and the existing one remains unchanged.
Add-WordCustomProperty $WordDocument 'Title' 'New Title'
Is there another method perhaps I should be using?
I just stumbled upon this project due to your post on the PowerShell Scripting group on Facebook. You mentioned in your overview that:
"Some of those commands are not yet finished and some are going to evolve. Some will get new features, some will be deprecated (or not really needed)."
What exactly needs to be worked on? Is there any way in which I can help?
When I add a table, I'd like to be able to specify the relative widths of each of the columns, such as: "30:50:20" for 30%, 50%, 20% of the 1st, 2nd, and 3rd columns. (Implicitly, I'm assuming "-autofit window" is used)
Thank you!
This leads to a:
Import-Module PSWriteWord -Force
$FilePath = "$Env:USERPROFILE\Desktop\PSWriteWord-Example-ListItems6.docx"
$ListOfItems = @('Test1', 'Test2')
$WordDocument = New-WordDocument $FilePath
Add-WordParagraph -WordDocument $WordDocument
$List = Add-WordList -WordDocument $WordDocument -ListType Numbered -ListData $ListOfItems -Supress $false
Set-WordList -List $List -FontSize 6 -FontFamily 'Tahoma' -Color Orange -Supress $True
$WordDocument.Paragraphs
$WordDocument.Lists
$WordDocument.ParagraphsDeepSearch
Save-WordDocument $WordDocument -Language 'en-US' -Supress $true
Invoke-Item $FilePath
Hi, I am having some trouble with Add-WordPicture
, see the following script
Import-Module PSWriteWord -Force
$FilePath = "$Env:USERPROFILE\Desktop\test1.docx"
$WordDocument = New-WordDocument $FilePath
$ImagePath = "$Env:USERPROFILE\Desktop\logo.png"
Add-WordPicture -WordDocument $WordDocument -ImagePath $ImagePath
Save-WordDocument $WordDocument
Invoke-Item $FilePath
I have one image file called "logo.png" on my desktop, where I create the new Word Document.
Whenever I call Add-WordPicture
- I get the following error
Exception calling "AddImage" with "1" argument(s): "Object reference not set to an instance of an object."
At C:\Program Files\WindowsPowerShell\Modules\PSWriteWord\0.5.8\Public\PSWordPicture.ps1:19 char:5
+ $Image = $WordDocument.AddImage($FilePathImage )
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NullReferenceException
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\PSWriteWord\0.5.8\Public\PSWordPicture.ps1:22 char:9
+ $Picture = $Image.CreatePicture()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Exception calling "AppendPicture" with "1" argument(s): "Object reference not set to an instance of an object."
At C:\Program Files\WindowsPowerShell\Modules\PSWriteWord\0.5.8\Public\PSWordPicture.ps1:30 char:5
+ $data = $Paragraph.AppendPicture($Picture)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NullReferenceException
Hi,
Awesome module, thanks!
I have some problems though with the new version
Error:
New-Object : Cannot find type [CustomProperty]: verify that the assembly containing this type is loaded.
At C:\Program Files\WindowsPowerShell\Modules\PSWriteWord\1.1.6\PSWriteWord.psm1:1094 char:23
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Version: 1.1.6
Expected behavior:
Same script i have works in 1.0.2 with Add-WordCustomProperty, but not in 1.1.6 but stuff like add-wordtable works.
Thanks for your great script!
I have created two word documents with custom word properties. If I merge the documents with Merge-WordDocument no errors occur but if I try to open the generated output document I get a Word error: "Word found unreadable content in xxx.docx. Do you want to recover the contents of this document?". The recovery works fine but the fixed document is quite strange:
The recovered (output) document only seems to contain the WordCustomProperties of the 1st Document BUT I can see the (merged) WordCustomProperties of the 2nd Document as fully working Fields (even the toggle field code looks fine) but the WordCustomProperties of the 2nd Document are definitely not listed in the (recovered output) document's custom word properties....
if you need further information or code please tell me. I am doing some tests with adding the 2nd document's WordCustomProperties manualy to the 1st document etc.
Would you expect this module to work correctly in an Azure function? In my function I can successfully Open new Word documents and Save them to the function local storage but they do populate with any content I send to them so I just end up with 5KB empty files.
Linked to #23 all shared modules require a License to be able to be used by others
Hi,
thank you so much for this great module!!
But i have a little Problem as you can see in the title.
I just have the parameter "position" at the "Add-WordTable"-Section.
But i cant figure out the position/line for my Bookmark.
With your functions i just can see the type and the name. Also the .xml-file doesn't show any informations for line...
At the moment i must define a static INT for setting the table on a specific position.
Maybe do you have an idea.
Best regards,
Leon
Repository needs to have a license
Following code $WordDocument.Tables[0].AutoFit
always returns ColumnWidth.
$WordDocument = New-WordDocument
$InvoiceEntry1 = @{}
$InvoiceEntry1.Description = 'IT Services 1'
$InvoiceEntry1.Amount = '$200'
$InvoiceEntry2 = @{}
$InvoiceEntry2.Description = 'IT Services 2'
$InvoiceEntry2.Amount = '$300'
$InvoiceEntry3 = @{}
$InvoiceEntry3.Description = 'IT Services 3'
$InvoiceEntry3.Amount = '$288'
$InvoiceEntry4 = @{}
$InvoiceEntry4.Description = 'IT Services 4'
$InvoiceEntry4.Amount = '$301'
$InvoiceEntry5 = @{}
$InvoiceEntry5.Description = 'IT Services 5'
$InvoiceEntry5.Amount = '$299'
$InvoiceData = @()
$InvoiceData += $InvoiceEntry1
$InvoiceData += $InvoiceEntry2
$InvoiceData += $InvoiceEntry3
$InvoiceData += $InvoiceEntry4
$InvoiceData += $InvoiceEntry5
Add-WordTable -WordDocument $WordDocument -DataTable $InvoiceData -Design MediumShading1 -AutoFit Contents #-Verbose
$WordDocument.Tables[0].RowCount | Should -Be 6
$WordDocument.Tables[0].ColumnCount | Should -Be 2
#$WordDocument.Tables[0].AutoFit | Should -Be 'Contents' # Seems like a bug in Xceed - always returns ColumnWidth
$WordDocument.Tables[0].Design | Should -Be 'MediumShading1'
Unable to create document. Error refers to Unable to find type [UnderlineStyle]. The line number it refers to does not exist and UnderlineStyle never called in the script. I copied the full script to ISE and ran debug with no issue. I am running VSCode Insiders and expecting it more a VSCode issue than the module.
Hi, its me again :)
i think i found some problems in the code.
Here in your "PSWordPicture" in the module the "{ return $data }" and the { return } should be exchanged. Otherwise the "supress" will not work.
And the Add-WordPicture does not work until i change the "-path"(in my script) to "$FilePathImage"...
As far as i can see this line in your "PSwordPicture" should be:
I hope this helps
When I was following the Add-WordTable examples, and trying to figure out how to use my own array as input, I noticed a bug.
Since your 1st row (Row 0) is for the header, you forgot to increment the corresponding index when pulling values from the array into the table.
So in the example code below, the table will be missing the row for "Joe", Cat Lover, 32.
(Also, is there any way to specify an order to the columns?)
$myitems = @(
[pscustomobject]@{name="Joe"; age=32; info="Cat lover"},
[pscustomobject]@{name="Sue"; age=29; info="Dog lover"},
[pscustomobject]@{name="Jason"; age=42; info="Food lover"}
)
Import-Module PSWriteWord #-Force
$FilePath = "C:\2\PSWriteWord-x.docx"
$WordDocument = New-WordDocument $FilePath
Add-WordTable -WordDocument $WordDocument -Table $myitems -Design 'ColorfulList' #-Verbose
Save-WordDocument $WordDocument
Hi,
i have the problem that there is no table-border when i create it with your module.
With "open Office" on the Server i can see borders. On my local computer(normal word) there are missing.
The Set-WordTable -Border/type or "Set-WordTableBorder" does not work(or i dont understand the syntax).
Thanks.
I found that the number of table columns can only be limited to 5,is a bug?
Is it posible to have different page orientations in the same document?
Ex page 1-4 is portrait and the next 2 pages is landscape and the return to portrait?
Best regards
Set-WordTableRowMergeCells delete worng paragraphs
script: PSWordTableRows.ps1
function: Set-WordTableRowMergeCells
rows: 109
# Removes Paragraphs from merged columns - Leaves only 1st column Text
for ($i = ($ColumnNrStart + 1); $i -gt $ColumnNrEnd ;$i++) {
foreach ($Paragraph in $Table.Rows[$RowNr].Cells[$i].Paragraphs) {
$Paragraph.Remove($TrackChanges)
}
}
Hi, thank you for this great Module!
In German we have "Umlaute" like äöü and so on. I did'nt found any way to handle this with your Module.
Can you give me a hint or fix somethin to do this?
Thank you very much.
Import-Module PSWriteWord -Force
$FilePath1 = "$($Env:USERPROFILE)\Desktop\EmptyDocument.docx"
$FilePath2 = "$($Env:USERPROFILE)\Desktop\PSWriteWord-Example-PageOrientation1.docx"
$FileOutput = "$($Env:USERPROFILE)\Desktop\Output.docx"
Merge-WordDocument -FilePath1 $FilePath1 -FilePath2 $FilePath2 -FileOutput $FileOutput -OpenDocument -Supress $true
If I try to add one hyperlink in a document, it works. But if I add more hyperlinks, the document can't be read by Word.
And if i let word correct the file, the urlText are correct but not the urlLink.
just trying with this demo:
Import-Module PSWriteWord #-Force
$FilePath = "$Env:USERPROFILE\Desktop\PSWriteWord-Example-HyperLinks1.docx"
$WordDocument = New-WordDocument -FilePath $FilePath
Add-WordText -WordDocument $WordDocument -Text 'This is my first title' -HeadingType Heading1 -Supress $True
$URL = Add-WordHyperLink -WordDocument $WordDocument -UrlText 'This is Google url' -UrlLink 'https://www.google.com'
$Paragraph = Add-WordParagraph -WordDocument $WordDocument
Set-WordHyperLink -WordDocument $WordDocument -Paragraph $Paragraph -Value $URL -Supress $True
$URL2 = Add-WordHyperLink -WordDocument $WordDocument -UrlText 'This is microsoft url' -UrlLink 'https://www.microsoft.com'
$Paragraph2 = Add-WordParagraph -WordDocument $WordDocument
Set-WordHyperLink -WordDocument $WordDocument -Paragraph $Paragraph2 -Value $URL2 -Supress $True
Save-WordDocument $WordDocument -Supress $True
Invoke-Item $FilePath
Import-Module pswriteword -Force
$FilePath = "$Env:USERPROFILE\Desktop\test111.docx"
$WordDocument = New-WordDocument $FilePath
$Table1 = new-WordTable -WordDocument $WordDocument -NrRows 3 -NrColumns 3
Add-WordTableCellValue -Table $Table1 -Row 0 -Column 0 -Value "test"
Set-WordTableRowMergeCells -Table $Table1 -RowNr 0 -ColumnNrStart 0 -ColumnNrEnd 2
Save-WordDocument -WordDocument $WordDocument
file: PSWordTableRows.ps1
Set-WordTableRowMergeCells line 101 work with:
for ($paragraph = 1; $paragraph -lt $Table.Rows[$RowNr].Cells[$ColumnNrStart].Paragraphs.Count; $paragraph++) {
module is not working in 2019 server encountering error "Get-WordDocument - Document: F:\server.docx Error: Unable to find type [Xceed.Words.NET.DocX]"
it is workign on my laptop windows 10 but same code is not working in server os I.e 2019 do it has any limitations or do we missed any modules kindly guide me.
I'm using the latest released version of PSWriteWord (https://github.com/EvotecIT/PSWriteWord/tree/v1.1.8), and an example snippet but I only get an empty file:
Import-Module $PSScriptRoot\PSWriteWord.psd1 -Force
$T1 = [PSCustomObject] @{
Test = 1
Test2 = 7
Ole = 'bole'
Trolle = 'A'
Alle = 'sd'
}
$T2 = [ordered] @{
Test = 1
Test2 = 7
Ole = 'bole'
Trolle = 'A'
Alle = 'sd'
}
$FilePath = "$Env:USERPROFILE\Desktop\PSWriteWord-Example-Tables9.docx"
$WordDocument = New-WordDocument $FilePath
Add-WordText -WordDocument $WordDocument -Text "Before" -Supress $true
Add-WordTable -WordDocument $WordDocument -DataTable $T1 -Design ColorfulGrid -Supress $true
Add-WordText -WordDocument $WordDocument -Text "After" -Supress $true
Add-WordTable -WordDocument $WordDocument -DataTable $T1 -Transpose -Design ColorfulGrid -Supress $true
Add-WordText -WordDocument $WordDocument -Text "Before T2" -Supress $true
Add-WordTable -WordDocument $WordDocument -DataTable $T2 -Design ColorfulGrid -Supress $true
Add-WordText -WordDocument $WordDocument -Text "After T2" -Supress $true
Add-WordTable -WordDocument $WordDocument -DataTable $T2 -Transpose -Design ColorfulGrid -Supress $true
Save-WordDocument $WordDocument -Language 'en-US' -Supress $True -OpenDocument
I think this problem is due to using PowerShell 6.2 instead of 5.*
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.