Copy link to clipboard
Copied
Hi everyone,
I have a script that formats tables that are imported as RTF. Everyone on my team loves it, but it doesn't work for one colleague.
Part of the script cuts the first row of the table, adds a heading row, and then pastes into that heading row. The problem for my colleague is that it's pasting whatever is on his clipboard before he ran the script. So, in essence, it's not doing the cut properly.
I thought it might be related to his INI file, but when I took his file and used it as my own, I didn't have any trouble.
Are there any other environmental settings that would prevent the CUT operation from working properly?
Thank y'all!!!
Heather A
**Also, if anyone is interested in the script, I'm happy to share. Just let me know.
Here's the code that handles the cutting and pasting just in case I'm doing something dumb and it just happens to be working for some people:
//Get the number of columns, but remember to subtract 1 for
//MakeTblSelection function which indexes from 0.
var num_columns = textItems.obj.TblNumCols -1;
//Add a new row to be used as the heading row
var row = textItems.obj.FirstRowInTbl;
row.AddRows(Constants.FV_Heading, 1); //Adds a heading row
//These 4 lines, select the now second row and cut it to the clipboard.
//This row was the original header row from the Word table.
//Next, paste the information to the new heading row
textItems.obj.MakeTblSelection(1, 1, 0, num_columns);
doc.Cut(Constants.FF_CUT_TBL_CELLS);
textItems.obj.MakeTblSelection(0, 0, 0, num_columns);
doc.Paste(Constants.FF_REPLACE_CELLS);
var row = textItems.obj.FirstRowInTbl;
//These two lines resize the table so that it fits into the 6.47 in page.
scaledColWidths = scaleTblMetrics(textItems.obj, targetTbleWidth);
textItems.obj.TblColWidths = scaledColWidths;
ApplyTableFormat(textItems.obj, doc);
ApplyTableTitle(textItems.obj,doc);
ApplyCellHeadingParaTag(textItems.obj, "CellHeading");
// AdjustWidth(textItems.obj,doc);
ApplyFullTableParaTag(textItems.obj, FullTablePgfTag);
cntTables++;
Copy link to clipboard
Copied
Hi Heather,
You need to use the PushClipboard and PopClipboard commands. Here is the sequence you use:
PushClipboard;
Cut (or Copy)
...
Paste
PopClipboard;
Here are the descriptions for the commands:
Void PushClipboard ([: Void]) Pushes the current Clipboard contents onto the Clipboard stack.The method is useful if you want to use Clipboard functions, such as Copy() or Cut(), without losing the Clipboard’s original contents.
On failure, the method assigns the following value to FA_errno:
Error
Reason
Constants.FE_Transport (-1)
A transport error occurred.
int PopClipboard ([_: Void]) Pops the Clipboard stack, moving the entry on the top of the stack to the Clipboard.
The method returns FE_Success on success. On failure, the method sets FA_errno to one of the following values:
Error
Reason
Constants.FE_Transport (-1)
A transport error occurred.
Constants.FE_BadOperation (-27)
Clipboard stack is empty.
Rick Quatro
Copy link to clipboard
Copied
I'll give it a try. Thanks so much!!!
Copy link to clipboard
Copied
I just wanted to follow up to my original post. Rick's suggestion about PushClipboard and PopClipboard was very helpful. I have built this into my script.
However, it was not the solution to the problem. My colleague was using the base version of FM 10 without the patches/updates. After he updated his system, he had no trouble. I just wanted to share this in case someone else was seeing isolated issues with only a few users.
Thanks again to Rick for his suggestion.
--Heather A