作者ptguitar (佩蒂吉他)
看板Office
標題Re: [算表] word vba文字方塊位置問題?
時間Sun Apr 16 11:42:20 2017
※ 引述《ptguitar (佩蒂吉他)》之銘言:
: ※ 引述《ptguitar (佩蒂吉他)》之銘言:
: : 軟體:excel,word
: : 版本:2007以上
: : 我想在excel內寫入word
如果加入文字框內
我若採用這樣寫
不知道該怎麼讓跳出文字方框後又回到最後一頁的最後一段?
Set box =
WdObj.ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal,
Left:=50, Top:=40, Width:=85, Height:=60)
box.Name = "密件"
'文字方塊內容設定
With box
With .TextFrame.TextRange
.Text = "密件"
With .Font
.Name = "標楷體"
.Size = 26
.Bold = msoTrue
End With ' Font
End With ' TextRange
End With 'box
'移動位置並且文字內容置中
.ActiveDocument.Shapes("密件").Select
.Selection.ShapeRange.IncrementLeft 418
.Selection.ShapeRange.IncrementTop -20
.Selection.ShapeRange.TextFrame.VerticalAnchor = msoAnchorMiddle
.Selection.ParagraphFormat.Alignment = 1
下面這段設定後還是會在密件的文字方塊內 不會跳到最後一頁...
.Selection.Collapse
.Selection.EscapeKey
.Selection.GoTo What:=wdGoToPage, Which:=wdGoToend
檔案:
https://drive.google.com/open?id=0BwCgrQhGgaw7bEhubnZVcEZCUjA
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.137.115.198
※ 文章網址: https://www.ptt.cc/bbs/Office/M.1492314143.A.B1E.html
※ 編輯: ptguitar (223.137.115.198), 04/16/2017 11:44:15
→ soyoso: 以selection.endkey試試 04/16 12:02
我下面改這樣還是不行 @@
.Selection.Collapse
.Selection.EndKey Unit:=wdStory, Extend:=wdMove
※ 編輯: ptguitar (223.137.115.198), 04/16/2017 14:35:13
我照上面那樣做是會出現參數錯誤
不過若是看下面這文章
https://msdn.microsoft.com/en-us/library/bb214015(v=office.12).aspx
wdStory 改成 6 又可以了
不知道會不會是2007版的問題了XD
※ 編輯: ptguitar (223.137.115.198), 04/16/2017 21:52:26
→ soyoso: 這並非版本的問題,而是引用項目 04/16 21:55
→ soyoso: 因原po回文是打"改這樣還是不行"而非提出會出現錯誤訊息 04/16 21:56
→ soyoso: 所以才會錄製以該selection.endkey是可跳到最後一頁 04/16 21:57
→ ptguitar: 感謝S大^^ 04/16 22:11