Last active
October 25, 2024 18:39
-
-
Save fearthecowboy/8830876 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#fixed now! | |
Param( | |
[string]$html, | |
[string]$docx | |
) | |
# make the powershell process switch the current directory. | |
$oldwd = [Environment]::CurrentDirectory | |
[Environment]::CurrentDirectory = $pwd | |
$html = resolve-path $html; | |
$docx = [IO.Path]::GetFullPath( $docx ) | |
[Environment]::CurrentDirectory = $oldwd | |
[ref]$SaveFormat = "microsoft.office.interop.word.WdSaveFormat" -as [type] | |
$word = New-Object -ComObject word.application | |
$word.visible = $false | |
"Converting $html to $docx..." | |
$doc = $word.documents.open($html) | |
$doc.saveas([ref] $docx, [ref]$SaveFormat::wdFormatDocumentDefault) | |
$doc.close() | |
$word.Quit() | |
$word = $null | |
[gc]::collect() | |
[gc]::WaitForPendingFinalizers() |
I share another script which converts html to docx without having office app installed.
https://github.com/lucianoybanez/ps-useful-scripts/tree/master/html-to-word-openxml
woow 👍
question: :now for docx to html, What to do?
The layout of Word content after converting has many mistakes.
Do you have met this situation?
The layout of Word content after converting has many mistakes. Do you have met this situation?
yes 🥴
The layout of Word content after converting has many mistakes. Do you have met this situation?
yes 🥴
Do you have solutions for this the situation?
I have met a problem - how to convert string of Latex formula in the Word document to Omml, so far i cannot a solution.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will check this out soon.