VBA & Macro Problems

How to Enter Time as hh:mm:ss Without Typing Colons in Word

Emma BrownEmma Brown Oct 13, 2026 870 views

Question details

The user needs a way to enter time into a Word document or form field in the hh:mm:ss format without having to manually type the colons.

How to Format Word Time Fields as hh:mm:ss Without Typing Colons
Product
Word Processor
Device & OS
not provided
Scenario
Filling out form fields or quickly logging time records within a document.
Observed behavior
Standard document form fields do not automatically convert a continuous number string (like 051732) into a properly colon-separated time format (05:17:32).
Before you start

Ensure that the Developer tab is enabled in your word processor's ribbon so you can access the VBA editor to create and run macros.

Solution 1Recommended

Use a VBA Macro to Insert Formatted Time as Text

Since native form fields do not auto-format strings into times with colons, you can use a short VBA macro to insert the current time directly in the correct HH:mm:ss format.

This approach utilizes a simple script that grabs the system's current time and inserts it at your cursor's location. Because it is inserted as plain text, you can easily edit the time after insertion if needed.

1
Open the VBA Editor

Press ALT + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the VBA editor menu, click on 'Insert' and select 'Module' to create a blank workspace for your code.

3
Paste the Macro Code

Copy and paste the following code into the module window: Sub InsertTimeM() Selection.TypeText Format(Now, "HH:mm:ss") End Sub

4
Run the Macro

Close the VBA editor. Place your cursor where you want the time to appear in the document, go to the Developer tab, click 'Macros', select 'InsertTimeM', and click 'Run'.

Use a VBA Macro to Insert Formatted Time as Text
Quick Access Tip: To save time, you can assign this macro to a custom keyboard shortcut or add it to your Quick Access Toolbar via the application options.
Efficient Document Editing

Automate Your Workflow with WPS Writer

WPS Writer offers an intuitive interface and excellent compatibility for handling form fields and advanced document automation. You can easily manage text formatting, use templates, and speed up repetitive tasks.

  1. 1. Open WPS Writer: Launch WPS Office and open your document in WPS Writer.
  2. 2. Access Developer Tools: Go to the options menu to enable the Developer tab on your ribbon.
  3. 3. Utilize Macro Features: Use the built-in macro tools (available in advanced versions) to paste your VBA script for time insertion.
  4. 4. Execute the Task: Run the script to automatically insert perfectly formatted hh:mm:ss time fields without typing colons.
High compatibility with Microsoft Word documents and form fields.Lightweight, fast, and completely free for basic editing needs.User-friendly interface with easy access to developer tools.Seamless migration of your existing Word templates and documents.
microsoft office alternative - wps office

Frequently Asked Questions

Can I format an existing number string like 051732 into a time format without using VBA?

Standard word processors do not have a built-in mask to automatically convert a 6-digit number string into a time format with colons. You either have to type the colons manually or use a VBA macro to handle the formatting.

How do I assign this time-insertion macro to a keyboard shortcut?

Go to File > Options > Customize Ribbon > Keyboard shortcuts. In the categories list, scroll down and select 'Macros', find your 'InsertTimeM' macro, press a new shortcut key combination (like Ctrl+Shift+T), and click Assign.

Will the time inserted by this macro update automatically like a clock?

No. The 'Selection.TypeText' method inserts the time as static text. It will remain exactly as the time it was when you ran the macro. If you need it to be modified, you can simply backspace and edit it like regular text.