{"id":64,"date":"2026-02-16T11:09:31","date_gmt":"2026-02-16T03:09:31","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=64"},"modified":"2026-01-17T06:14:18","modified_gmt":"2026-01-17T06:14:18","slug":"how-to-create-text-box-using-xlwings","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-create-text-box-using-xlwings\/","title":{"rendered":"How To Create Text Box Using xlwings?"},"content":{"rendered":"<h2>Method<\/h2>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">Use the `AddTextbox` method of the `Shapes` object to create a text box. The calling format and parameters are similar to the `AddLabel` method.<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 8.0pt;\">\u00a0<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">shp=sht.api.Shapes.AddTextbox(1,10,10,100,50)<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">shp.TextFrame2.TextRange.Characters.Text=&#8217;Test Box&#8217;<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Create formulas using defined names\n\nimport xlwings as xw    #Import the xlwings package\nimport os    #Import the os package\n\nroot = os.getcwd()    #Get the current path\n#Create an Excel application window, visible, \n#without opening a workbook  \napp=xw.App()\nbk=app.books.active\nsht=bk.api.Sheets(1)    #Get the worksheet\n\n#Create formulas using defined names\nsht.Range('C3').Value=10\nsht.Names.Add(Name='NMT',RefersTo=sht.Range('C3').Value)\nsht.Range('A1').Formula='=NMT+3'\n\n#bk.save()\n#bk.close()\n#app.kill()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"482\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/62.png\" alt=\"Create Text Box Using xlwings\" class=\"wp-image-383\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/62.png 780w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/62-300x185.png 300w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/62-768x475.png 768w\" sizes=\"auto, (max-width: 780px) 100vw, 780px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Method<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-xlwings-shape"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":3,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":384,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions\/384"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}