小问题?

MYLP 2003-12-22 08:08:00
wordapp=new ActiveXObject("Word.Application")
function printEntry(){
for(n=1;n<=10;n++){
wordapp.documents.Add("d:\PrintForm.dot") ;
for(i=1;i<151;i++){
mark="bookmark"+i; wordapp.activedocument.bookmarks(mark).select();
if (i==81)
{ 插入一个TABLE,并且要得到Table object,对其进行
行增加,单元格复值操作
}
else
{
wordapp.wordbasic.insert(mm[n][i]);
}
}
wordapp.activedocument.printout();
}
帮忙解决一下吧!谢谢!
...全文
43 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
MYLP 2003-12-23
  • 打赏
  • 举报
回复
我没有说清楚,我说的插入Table 指的是在PrintForm.dot Word 模板中。
我的目的是要在 PrintForm.dot中赋完值,最后打印出来。所有的操作都需要ActiveXObject.
MYLP 2003-12-23
  • 打赏
  • 举报
回复
谢谢 yjgx007(谁是高手)!
yjgx007 2003-12-22
  • 打赏
  • 举报
回复
table对象不支持innertHTML的操作(只能读该属性)
MSDN上有一个关于table object操作的一个小游戏,挺有意思的,或许有些帮助

-------------------------------

<HTML>
<HEAD>
<TITLE>Unscramble Table Cells Game</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-8859-1">
<META NAME="AUTHOR" CONTENT="InetSDK">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="ROBOTS" CONTENT="noindex">

<!-- SAMPLE_STYLE_START -->
<LINK REL="stylesheet" HREF="../../../../msdn-online/shared/css/ie4.css" TYPE="text/css">
<!-- SAMPLE_STYLE_END -->

<STYLE>
TD { width:83px; height:48px; text-align:center; }
IMG { width:81px; height:46px; }
</STYLE>
</HEAD>
<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END-->

<BODY TOPMARGIN=0 LEFTMARGIN=0 BGPROPERTIES="FIXED" BGCOLOR="#B3CCFF" LINK="#000000" VLINK="#808080" ALINK="#000000">
<!-- CONTENTS_START -->
<BLOCKQUOTE>
<H2>The Unscramble Table Cells Game</H2>
<B>Instructions</B>: Click a puzzle piece to select it. If you click the wrong piece, click it again to deselect it. Click a second puzzle piece to swap it with the selected piece.<BR><BR>
<DIV ALIGN="center">
<TABLE ID=oTable>
</TABLE>
<BR>
Number of swaps: <SPAN ID=numSwaps>0</SPAN><BR><BR>
<SPAN ID=winnerText></SPAN><BR><BR>
<INPUT TYPE="button" VALUE="Scramble" onClick="scrambleCells();">
</DIV>
</BLOCKQUOTE>
<SCRIPT LANGUAGE="JScript">
var lastSelection = null;
var nSwaps = 0;

window.onload = fnInit;

function fnInit()
{
var oRow;
var iRow, iCol;

for (iRow = 0; iRow < 3; iRow++) {
oRow = oTable.insertRow();
for (iCol = 0; iCol < 3; iCol++) {
oRow.insertCell();
}
}

scrambleCells();
}

function getRandom(maxValue) {
// Create an instance of the current date.
var now = new Date();

// Create a random number.
var num = now.getTime() * now.getSeconds() * Math.random();

// Cut random number to an integer value between 0 and maxValue, inclusive.
return Math.round(num % maxValue);
}

function scrambleCells()
{
var arr, nIndex, nRnd, arrCount, bFound, iRow, iCol;

arr = new Array(9);

// Fill the array with values from 0 - 8 in a random order.
for (nIndex = 0; nIndex < 9; nIndex++) {
bFound = 1;

// Generate a random integer value from 0 - 8.
while (bFound == 1) {
bFound = 0;
nRnd = getRandom(8);

// Go back through the array and make sure the number isn't already there.
for (arrCount = nIndex; arrCount >= 0; arrCount--) {
if (arr[arrCount] == nRnd) {
bFound = 1; // Oops! Found it, try again.
} // end if
} // end for

} // end while

arr[nIndex] = nRnd;

} // end for

// Populate the table
nIndex = 0;
for (iRow = 0; iRow < 3; iRow++) {
theRow=oTable.rows(iRow);
for (iCol = 0; iCol < 3; iCol++) {
theRow.cells(iCol).innerHTML = "<img src=" + arr[nIndex] + ".jpg>"
nIndex++;
}
}

// Deselect all the cells in case there was a winner in the last game.
nIndex = 0;
for (iRow = 0; iRow < 3; iRow++) {
theRow=oTable.rows(iRow);
for (iCol = 0; iCol < 3; iCol++) {
deselectCell(oTable.rows(iRow).cells(iCol));
nIndex++;
} // end for
} // end for

winnerText.innerText = "";
nSwaps = 0;
numSwaps.innerText = nSwaps;
}

function onclickCell()
{
var e, c;

// Do not accept clicks if there's been a winner.
if (winnerText.innerText != "") {
window.event.cancelBubble = true;
return;
}

e = window.event.srcElement;
c = findCell(e);

if (c != null) {
if (lastSelection == null) {
selectCell(c);
lastSelection = c;
}
else {
if (c == lastSelection) {
deselectCell(lastSelection);
}
else {
c.swapNode(lastSelection);
deselectCell(lastSelection);
nSwaps += 1;
numSwaps.innerText = nSwaps;
checkWinner();
}
lastSelection = null;
}
}
window.event.cancelBubble = true;
}

function findCell(e)
{
if (e.tagName == "TD") {
return e;
}
else if (e.tagName == "BODY") {
return null;
}
else {
return findCell(e.parentElement);
}
}

function selectCell(c)
{
c.runtimeStyle.backgroundColor = "red";
c.runtimeStyle.color = "white";
}

function cancelSelect()
{
if (lastSelection != null) {
deselectCell(lastSelection);
lastSelection = null;
}
}

function deselectCell(c)
{
c.runtimeStyle.backgroundColor = "white";
c.runtimeStyle.color = "white";
}

function checkWinner()
{
var bWinner = 1; // Assume we have a winner.
var nIndex = 0;
var sFilename;

for (iRow = 0; iRow < 3; iRow++) {
theRow=oTable.rows(iRow);
for (iCol = 0; iCol < 3; iCol++) {
sFilename = theRow.cells(iCol).innerHTML;
sFilename = sFilename.substring(sFilename.length - 7, sFilename.length - 6);
if (sFilename != nIndex) {
bWinner = 0; // Had a mismatch, no winner.
}
nIndex++;
}
}

if (bWinner == 1) {
// Display the winner text.
winnerText.innerHTML="<font color='red'><b>Winner!!!</b></font><br><br>Click the Scramble button to play again.";

// Select all the cells, just to look cool for the winner.
nIndex = 0;
for (iRow = 0; iRow < 3; iRow++) {
theRow=oTable.rows(iRow);
for (iCol = 0; iCol < 3; iCol++) {
selectCell(oTable.rows(iRow).cells(iCol));
nIndex++;
} // end for
} // end for

} // end if
}

oTable.onclick = onclickCell;
document.onclick = cancelSelect;
</SCRIPT>
<!-- CONTENTS_END -->
<!-- START_PAGE_FOOTER -->
<BR>
<BLOCKQUOTE>
© <A CLASS="clsIncCpyRt" HREF="http://msdn.microsoft.com/misc/cpyright.htm" TARGET="_top">2000 Microsoft Corporation. All rights reserved. Terms of use</A>.
</BLOCKQUOTE>
<!-- END_PAGE_FOOTER -->
</BODY>
</HTML>
yjgx007 2003-12-22
  • 打赏
  • 举报
回复
if (i==81){
document.write("<table id=tab1></table>");
eval("oRow = tab1.insertRow()");
eval("oCell = oRow.insertCell()");
eval("oCell.innerHTML = 'Download the latest version of <I>Internet Explorer</I> from here.'");

}

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧