Skip to content

Commit b9754c8

Browse files
authored
Merge pull request #24 from DecimalTurn/dev-dotm
2 parents 879886b + fb882ca commit b9754c8

54 files changed

Lines changed: 5418 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

scripts/Build-VBA.ps1

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ if ($outputFilePath.EndsWith(".xltm")) {
4343
$outputFilePath = $outputFilePath -replace "\.xltm$", ".xltm.xlsm"
4444
}
4545

46+
if ($outputFilePath.EndsWith(".dotm")) {
47+
$outputFilePath = $outputFilePath -replace "\.dotm$", ".dotm.docm"
48+
}
49+
50+
if ($outputFilePath.EndsWith(".potm")) {
51+
$outputFilePath = $outputFilePath -replace "\.potm$", ".potm.pptm"
52+
}
53+
4654
if ($outputFilePath.EndsWith(".ppam")) {
4755
$outputFilePath = $outputFilePath -replace "\.ppam$", ".ppam.pptm"
4856
}
@@ -296,9 +304,23 @@ Write-Host "Saving document..."
296304
$oldFilePath = ""
297305
try {
298306
if ($officeAppName -eq "Word") {
299-
# For PowerPoint, use SaveAs with the same file name to force save
300-
$doc.SaveAs($outputFilePath)
301-
Write-Host "Document saved using SaveAs method"
307+
# For Word, check if the file name ends with .dotm.docm
308+
# If so, we need to save as .dotm
309+
if ($outputFilePath.EndsWith(".dotm.docm")) {
310+
$oldFilePath = $outputFilePath
311+
$outputFilePath = $outputFilePath -replace "\.dotm\.docm$", ".dotm"
312+
# Replace forward slashes with backslashes
313+
$outputFilePath = $outputFilePath -replace "/", "\"
314+
Write-Host "Saving document as .dotm: $outputFilePath"
315+
$doc.SaveAs($outputFilePath, 15) # 15 is the wdFormatXMLTemplateMacroEnabled file format for .dotm
316+
# Delete the .dotm.docm file
317+
Remove-Item -Path $oldFilePath -Force
318+
Write-Host "Document saved as .dotm at ${doc.Path}"
319+
} else {
320+
# We just use SaveAs since it's a normal Word document
321+
$doc.SaveAs($outputFilePath)
322+
Write-Host "Document saved using SaveAs method"
323+
}
302324
} elseif ($officeAppName -eq "PowerPoint") {
303325
# For PowerPoint, we need to check if the file name ends with .ppam.pptm
304326
# If so, we need to save as .ppam
@@ -312,6 +334,19 @@ try {
312334
# Delete the .ppam.pptm file
313335
Remove-Item -Path $oldFilePath -Force
314336
Write-Host "Document saved as .ppam"
337+
338+
# Check if the extension is .potm and if so save as .potm
339+
} elseif ($outputFilePath.EndsWith(".potm.pptm")) {
340+
$oldFilePath = $outputFilePath
341+
$outputFilePath = $outputFilePath -replace "\.potm\.pptm$", ".potm"
342+
# Replace forward slashes with backslashes
343+
$outputFilePath = $outputFilePath -replace "/", "\"
344+
Write-Host "Saving document as .potm: $outputFilePath"
345+
$doc.SaveAs($outputFilePath, 17) # 17 is the ppSaveAsOpenXMLTemplateMacroEnabled file format for .potm
346+
# Delete the .potm.pptm file
347+
Remove-Item -Path $oldFilePath -Force
348+
Write-Host "Document saved as .potm"
349+
315350
} else {
316351
$doc.Save()
317352
Write-Host "Document saved successfully"

scripts/Rename-It.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ if ($fileExtension -eq "xltm") {
3131
$fileExtension = "xltm.xlsm"
3232
}
3333

34+
# Since we can't edit the .dotm file directly, we will use the .dotm.docm file extension
35+
if ($fileExtension -eq "dotm") {
36+
$fileExtension = "dotm.docm"
37+
}
38+
39+
# Since we can't edit the .potm file directly, we will use the .potm.pptm file extension
40+
if ($fileExtension -eq "potm") {
41+
$fileExtension = "potm.pptm"
42+
}
43+
3444
# Since we can't edit the .ppam file directly, we will use the .pptm file extension
3545
if ($fileExtension -eq "ppam") {
3646
$fileExtension = "ppam.pptm"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Attribute VB_Name = "Module1"
2+
3+
'@Lang VBA
4+
Option Explicit
5+
6+
Sub Demo()
7+
MsgBox "Hello, World!"
8+
End Sub
9+
10+
'This code will be called via COM to test if the VBA import was successful
11+
Sub WriteToFile()
12+
Dim filePath As String
13+
Dim fileNum As Integer
14+
15+
' Specify the path to the text file
16+
filePath = ThisPresentation.Path & "\PowerPointPresentation.txt"
17+
18+
' Get a free file number
19+
fileNum = FreeFile
20+
21+
' Open the file for output
22+
Open filePath For Output As #fileNum
23+
24+
' Write some text to the file
25+
Print #fileNum, "Hello, World!"
26+
27+
' Close the file
28+
Close #fileNum
29+
End Sub
30+
31+
Private Function ThisPresentation() As PowerPoint.Presentation
32+
Dim Pres As Presentation
33+
On Error Resume Next
34+
Set Pres = Presentations("PowerPointPresentation.pptm")
35+
On Error GoTo 0
36+
If Pres Is Nothing Then
37+
'Try to fallback using ActiveVBProject
38+
Dim PresName As String
39+
PresName = Split(Application.VBE.ActiveVBProject.FileName, "\")(UBound(Split(Application.VBE.ActiveVBProject.FileName, "\")))
40+
Set Pres = Presentations(PresName)
41+
End If
42+
Set ThisPresentation = Pres
43+
Exit Function
44+
End Function
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
3+
<Default Extension="jpeg" ContentType="image/jpeg" />
4+
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
5+
<Default Extension="xml" ContentType="application/xml" />
6+
<Override PartName="/ppt/presentation.xml" ContentType="application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml" />
7+
<Override PartName="/ppt/slideMasters/slideMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml" />
8+
<Override PartName="/ppt/slides/slide1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml" />
9+
<Override PartName="/ppt/presProps.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presProps+xml" />
10+
<Override PartName="/ppt/viewProps.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml" />
11+
<Override PartName="/ppt/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml" />
12+
<Override PartName="/ppt/tableStyles.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml" />
13+
<Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" />
14+
<Override PartName="/ppt/slideLayouts/slideLayout2.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" />
15+
<Override PartName="/ppt/slideLayouts/slideLayout3.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" />
16+
<Override PartName="/ppt/slideLayouts/slideLayout4.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" />
17+
<Override PartName="/ppt/slideLayouts/slideLayout5.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" />
18+
<Override PartName="/ppt/slideLayouts/slideLayout6.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" />
19+
<Override PartName="/ppt/slideLayouts/slideLayout7.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" />
20+
<Override PartName="/ppt/slideLayouts/slideLayout8.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" />
21+
<Override PartName="/ppt/slideLayouts/slideLayout9.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" />
22+
<Override PartName="/ppt/slideLayouts/slideLayout10.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" />
23+
<Override PartName="/ppt/slideLayouts/slideLayout11.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" />
24+
<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml" />
25+
<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" />
26+
</Types>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
3+
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" />
4+
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail" Target="docProps/thumbnail.jpeg" />
5+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml" />
6+
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" />
7+
</Relationships>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
3+
<TotalTime>2</TotalTime>
4+
<Words>0</Words>
5+
<Application>Microsoft Office PowerPoint</Application>
6+
<PresentationFormat>Widescreen</PresentationFormat>
7+
<Paragraphs>0</Paragraphs>
8+
<Slides>1</Slides>
9+
<Notes>0</Notes>
10+
<HiddenSlides>0</HiddenSlides>
11+
<MMClips>0</MMClips>
12+
<ScaleCrop>false</ScaleCrop>
13+
<HeadingPairs>
14+
<vt:vector size="6" baseType="variant">
15+
<vt:variant>
16+
<vt:lpstr>Fonts Used</vt:lpstr>
17+
</vt:variant>
18+
<vt:variant>
19+
<vt:i4>3</vt:i4>
20+
</vt:variant>
21+
<vt:variant>
22+
<vt:lpstr>Theme</vt:lpstr>
23+
</vt:variant>
24+
<vt:variant>
25+
<vt:i4>1</vt:i4>
26+
</vt:variant>
27+
<vt:variant>
28+
<vt:lpstr>Slide Titles</vt:lpstr>
29+
</vt:variant>
30+
<vt:variant>
31+
<vt:i4>1</vt:i4>
32+
</vt:variant>
33+
</vt:vector>
34+
</HeadingPairs>
35+
<TitlesOfParts>
36+
<vt:vector size="5" baseType="lpstr">
37+
<vt:lpstr>Aptos</vt:lpstr>
38+
<vt:lpstr>Aptos Display</vt:lpstr>
39+
<vt:lpstr>Arial</vt:lpstr>
40+
<vt:lpstr>Office Theme</vt:lpstr>
41+
<vt:lpstr>PowerPoint Presentation</vt:lpstr>
42+
</vt:vector>
43+
</TitlesOfParts>
44+
<Company>
45+
</Company>
46+
<LinksUpToDate>false</LinksUpToDate>
47+
<SharedDoc>false</SharedDoc>
48+
<HyperlinksChanged>false</HyperlinksChanged>
49+
<AppVersion>16.0000</AppVersion>
50+
</Properties>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
<dc:title>
4+
</dc:title>
5+
<dc:creator>Martin Leduc</dc:creator>
6+
<cp:lastModifiedBy>Martin Leduc</cp:lastModifiedBy>
7+
<cp:revision>1</cp:revision>
8+
<dcterms:created xsi:type="dcterms:W3CDTF">2025-04-19T01:26:16Z</dcterms:created>
9+
<dcterms:modified xsi:type="dcterms:W3CDTF">2025-04-19T01:28:20Z</dcterms:modified>
10+
</cp:coreProperties>
1.17 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
3+
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps" Target="presProps.xml" />
4+
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide1.xml" />
5+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="slideMasters/slideMaster1.xml" />
6+
<Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles" Target="tableStyles.xml" />
7+
<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml" />
8+
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps" Target="viewProps.xml" />
9+
</Relationships>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<p:presentationPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
3+
<p:extLst>
4+
<p:ext uri="{E76CE94A-603C-4142-B9EB-6D1370010A27}">
5+
<p14:discardImageEditData xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="0" />
6+
</p:ext>
7+
<p:ext uri="{D31A062A-798A-4329-ABDD-BBA856620510}">
8+
<p14:defaultImageDpi xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="32767" />
9+
</p:ext>
10+
<p:ext uri="{FD5EFAAD-0ECE-453E-9831-46B23BE46B34}">
11+
<p15:chartTrackingRefBased xmlns:p15="http://schemas.microsoft.com/office/powerpoint/2012/main" val="1" />
12+
</p:ext>
13+
</p:extLst>
14+
</p:presentationPr>

0 commit comments

Comments
 (0)