OneDrive won't sync .docx created from macro-enabled template (.dotm) found a "workaround" (re-triggering the file, sync starts) [WORD]
>Context: I was trying to make a template for my Uni so that I don't need to manually edit anything, but I ran into two issues which I kind-of Solved
Ms Word Ver: MS Word-365 (2026)
Windows Ver: Windows 10 Pro (Home would work too maybe)
OneDrive: Uni Acc. (Personal Would work too maybe)
Problem: File Not Auto-Syncing. Error: Macro Enabled, disabling it
Fix: Just click on the 'File' Section and it will Auto-Sync
[How to use Macro/ .dotm Template]
Step 1: Make your template file first
Step 2: Save it as ".dotm" [Word will automatically save it at it's default position, re-open it and press Left-Alt + F11
Step 3: Double click on "ThisDocument" and paste the given macro with your formatting
Step 4: Save it 'CTRL+S' and exit everything, re-open word.
Step 5: Below the "Good Morning-etc." Greetings will be the template section, click on "More Templates" and head to "Personal" Section, Open the file and it should automatically save, Do the work-around I suggested.
Macro/ VBA Used:
Dim srNo As String
srNo = InputBox("Enter Experiment No.:", "New Document")
' Only Edit the "Enter Exp No.: " if needed.
If srNo = "" Then Exit Sub
Dim defaultName As String
defaultName = "YourExpName" & srNo & "-YourID.docx"
Dim saveFolder As String
saveFolder = "OneDrive Folder Path"
' Since the post is for OneDrive Sync i.e One-Drive Path
' Create the folder if it doesn't exist yet
If Dir(saveFolder, vbDirectory) = "" Then
MkDir saveFolder
End If
ActiveDocument.SaveAs2 FileName:=saveFolder & defaultName, _
FileFormat:=wdFormatXMLDocumentPrivate Sub Document_New()
End Sub
If anyone has a better way to do it please comment on this post