[算表] word vba文字方塊位置問題?

看板Office作者 (佩蒂吉他)時間9年前 (2017/04/13 16:58), 9年前編輯推噓0(004)
留言4則, 1人參與, 最新討論串1/3 (看更多)
軟體:excel,word 版本:2007以上 我想在excel內寫入word 現在想要在word新增一個textbox 裡面還要輸入文字 現在問題是 我要怎麼指定這個textbox是出現在第一頁的最上端的右邊 (這vba會產生很多頁 目前這樣寫都會跑到最後一頁) 然後裡面要有文字 【密件】 不知道這怎麼設定 翻了好多網路說明都沒有很清楚... 以下為片段巨集 With WdObj .Visible = False '執行時候不要看見word .Documents.Add '增加一個新的word檔案' .ActiveDocument.PageSetup.TopMargin = 71 '上邊界 .ActiveDocument.PageSetup.BottomMargin = 71 '下邊界 .ActiveDocument.PageSetup.LeftMargin = 71 '左邊界 .ActiveDocument.PageSetup.RightMargin = 71 '右邊界 .Selection.Font.Size = 18 .Selection.Font.Bold = True .Selection.Font.Name = "標楷體" .ActiveDocument.Shapes.AddTextbox _ Orientation:=msoTextOrientationHorizontal, _ Left:=50, Top:=50, Width:=70, Height:=50 .Selection.TypeParagraph .Selection.TypeParagraph .Selection.TypeParagraph .Selection.TypeParagraph .Selection.ParagraphFormat.Alignment = 1 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.250.67.77 ※ 文章網址: https://www.ptt.cc/bbs/Office/M.1492073918.A.ADC.html ※ 編輯: ptguitar (60.250.67.77), 04/13/2017 16:59:24

04/13 17:37, , 1F
可以selection.goto的方式回到第1頁,再新增該textbox
04/13 17:37, 1F

04/13 17:39, , 2F
置入文字則以shapes.textframe.textrange.text
04/13 17:39, 2F
謝謝S大 不過如果照我上面的寫法 我不知道要怎麼加入shapes.textframe.textrange.txt 是用指定textbox(1)? 但我試不出來該怎麼寫進去

04/13 17:43, , 3F
回到第1頁另有selection.homekey
04/13 17:43, 3F
※ 編輯: ptguitar (60.250.67.77), 04/14/2017 11:56:21

04/14 13:54, , 4F
set一個變數類型為shape的變數指定到addtextbox
04/14 13:54, 4F
文章代碼(AID): #1Oxps-hS (Office)
文章代碼(AID): #1Oxps-hS (Office)