Change Font Size in word

How to change the Font size in a word document in UiPath

Hi @MEGHA_cs
Try this

Hi @MEGHA_cs

To change the font size in a Word document using UiPath, you can follow these steps:

  1. Open UiPath Studio and create a new project or open an existing one.
  2. Drag and drop an “Open Application” activity onto the workflow.
  3. Configure the “Open Application” activity to open Microsoft Word by providing the path to the Word application or by selecting it from the list of available applications.
  4. Add a “Click” activity to click on the “Home” tab in the Word application. This tab contains the font formatting options.
  5. Use another “Click” activity to select the “Font Size” dropdown or button.
  6. Add a “Type Into” activity to enter the desired font size value. Set the target as the dropdown or input field for font size.
  7. Configure the “Type Into” activity to provide the font size value. You can either provide a specific value or use a variable.
  8. Add a “Click” activity to select the desired font size from the dropdown list. You may need to use the “Indicate on screen” option to indicate the specific size from the dropdown list.
  9. Finally, add a “Click” activity to save the changes and close the Word application

Hope it helps!!

Thanks…

But can you tell me how to do this using Vb code in Invoke code activity?

@MEGHA_cs Use the below VB code to change the font size in word. Write all this in Invoke code activity.

Imports Microsoft.Office.Interop.Word
Imports System.Runtime.InteropServices

Dim wordApp As New Application()
Dim wordDoc As Document = wordApp.Documents.Open(“C:\path\to\your\document.docx”)

Dim range As Range = wordDoc.Content
range.Font.Size = 12 ’ Set the desired font size

wordDoc.Save()
wordDoc.Close()

Marshal.ReleaseComObject(wordDoc)
Marshal.ReleaseComObject(wordApp)
wordDoc = Nothing
wordApp.Quit()
Marshal.FinalReleaseComObject(wordApp)

Hope it helps!!

Thanks @mkankatala ,

But am getting error

May I know the error you are catching @MEGHA_cs

Hey I just removed these lines

Marshal.ReleaseComObject(wordDoc)
Marshal.ReleaseComObject(wordApp)
wordDoc = Nothing
wordApp.Quit()
Marshal.FinalReleaseComObject(wordApp)

And its working fine… Thank you

Hi @mkankatala ,

Please tell me how to add a blank page to a word document using vb code in UiPath

Hi @MEGHA_cs

Try this

Sub AddBlankPage()
Dim wdApp As Microsoft.Office.Interop.Word.Application = GetObject(, “Word.Application”)
Dim wdDoc As Microsoft.Office.Interop.Word.Document = wdApp.ActiveDocument

' Insert a blank page
wdDoc.Bookmarks("\Page").Range.InsertBreak Type:=Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak

End Sub

I hope it helps!!

Thank you @MEGHA_cs

Happy Automation!!

Thanks a lot…

And one more thing, How to change Font size of the Data in Datatable

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.