W wAng.Net Unregistered / Unconfirmed GUEST, unregistred user! 2001-12-03 #1 向模板中插入图片的问题 , 那位大虾搞定过吗 ,能将Source Code 发给我吗 ? xlw9644580@sina.com 非常感谢。
B bluerain Unregistered / Unconfirmed GUEST, unregistred user! 2001-12-03 #2 首先确定你的document中BookMarks是否有.如果有的话,你的代码应该没什么问题. 下面是我的一段试验性代码,测试通过了. var LinkToFile,SaveWithDocument,Rng : OleVariant; Index : OleVariant; begin Index := 1; LinkToFile := False; SaveWithDocument := True; Rng :=WordDoc.Bookmarks.Item(Index).Range; WordDoc.InlineShapes.AddPicture('c:/testimg.jpg',LinkToFile,SaveWithDocument,Rng); end;
首先确定你的document中BookMarks是否有.如果有的话,你的代码应该没什么问题. 下面是我的一段试验性代码,测试通过了. var LinkToFile,SaveWithDocument,Rng : OleVariant; Index : OleVariant; begin Index := 1; LinkToFile := False; SaveWithDocument := True; Rng :=WordDoc.Bookmarks.Item(Index).Range; WordDoc.InlineShapes.AddPicture('c:/testimg.jpg',LinkToFile,SaveWithDocument,Rng); end;
Y YB_unique Unregistered / Unconfirmed GUEST, unregistred user! 2001-12-03 #3 呵呵!给你一个函数! Function InsertPicture(AFileName : String) : Boolean; var MyShapes : Variant; MyRange : variant; begin Result := True; If GetWordUp('Current')then Try Begin MyRange := MyDocument.Goto(wdgotoline, wdgotolast); MyRange.EndOf(wdParagraph, wdMove); MyRange.InsertBreak(wdPageBreak); MyShapes := MyDocument.InlineShapes; MyShapes.AddPicture(afilename, false, true, MyRange); end; Finally begin Wordy.ScreenUpdating:= true; Wordy.visible := true; Wordy := Unassigned; Basically := UnAssigned; Application.ProcessMessages; end; end else Result := False; end;
呵呵!给你一个函数! Function InsertPicture(AFileName : String) : Boolean; var MyShapes : Variant; MyRange : variant; begin Result := True; If GetWordUp('Current')then Try Begin MyRange := MyDocument.Goto(wdgotoline, wdgotolast); MyRange.EndOf(wdParagraph, wdMove); MyRange.InsertBreak(wdPageBreak); MyShapes := MyDocument.InlineShapes; MyShapes.AddPicture(afilename, false, true, MyRange); end; Finally begin Wordy.ScreenUpdating:= true; Wordy.visible := true; Wordy := Unassigned; Basically := UnAssigned; Application.ProcessMessages; end; end else Result := False; end;
W wAng.Net Unregistered / Unconfirmed GUEST, unregistred user! 2001-12-03 #4 谢谢两位了, 原来是自己犯了一个错误。Shy ..