Copy and paste a table from one word document to another SAS DDE
I'm using SAS v9.4, running a connection via DDE to Word 2010.
I would like to copy and paste an entire table from onw word document to another. The table is bookmarked "IDX" and I am able to select the table using the following code:
options noxsync noxwait xmin;
filename sas2word dde 'winword|system';
data _null_;
file sas2word;
put '[EditGoTo.Destination = "IDX"]';
put '[TableSelectTable]';
run;
I have tried put '[ctrl+c]';
, put '[copy]';
, put '[TableCopy]';
, put '[SelectionCopy]';
but nothing seems to work, and the code crashes. Does anyone know the syntax to copy the entire table, then paste it into a different document?
ms-word sas dde
|
show 3 more comments
I'm using SAS v9.4, running a connection via DDE to Word 2010.
I would like to copy and paste an entire table from onw word document to another. The table is bookmarked "IDX" and I am able to select the table using the following code:
options noxsync noxwait xmin;
filename sas2word dde 'winword|system';
data _null_;
file sas2word;
put '[EditGoTo.Destination = "IDX"]';
put '[TableSelectTable]';
run;
I have tried put '[ctrl+c]';
, put '[copy]';
, put '[TableCopy]';
, put '[SelectionCopy]';
but nothing seems to work, and the code crashes. Does anyone know the syntax to copy the entire table, then paste it into a different document?
ms-word sas dde
TryCopy
, capital C andPaste
with capital P. Those have been around for a long time, it's hard to imagine they're different. Have you checked the Excel reference for what it was then?
– Reeza
Jan 2 at 1:04
1
Also, if you're working with multiple files you may want to have specific filerefs for each, or it will be hard to know which is going where.
– Reeza
Jan 2 at 1:06
UnfortunatelyCopy
andPaste
don't work, they just crash in the same way :( I like the idea about different filerefs, once I get copy/paste to work within one document I'll definitely try and implement that. I found an Excel reference tocopy()
here: communities.sas.com/t5/SAS-Programming/…, but that also crashes so I'm not sure what is going wrong
– RAB
Jan 2 at 1:13
Do you have the parenthesis included in the command?
– Reeza
Jan 2 at 1:21
I've tried with and without the parenthasis, neither work :(
– RAB
Jan 2 at 1:25
|
show 3 more comments
I'm using SAS v9.4, running a connection via DDE to Word 2010.
I would like to copy and paste an entire table from onw word document to another. The table is bookmarked "IDX" and I am able to select the table using the following code:
options noxsync noxwait xmin;
filename sas2word dde 'winword|system';
data _null_;
file sas2word;
put '[EditGoTo.Destination = "IDX"]';
put '[TableSelectTable]';
run;
I have tried put '[ctrl+c]';
, put '[copy]';
, put '[TableCopy]';
, put '[SelectionCopy]';
but nothing seems to work, and the code crashes. Does anyone know the syntax to copy the entire table, then paste it into a different document?
ms-word sas dde
I'm using SAS v9.4, running a connection via DDE to Word 2010.
I would like to copy and paste an entire table from onw word document to another. The table is bookmarked "IDX" and I am able to select the table using the following code:
options noxsync noxwait xmin;
filename sas2word dde 'winword|system';
data _null_;
file sas2word;
put '[EditGoTo.Destination = "IDX"]';
put '[TableSelectTable]';
run;
I have tried put '[ctrl+c]';
, put '[copy]';
, put '[TableCopy]';
, put '[SelectionCopy]';
but nothing seems to work, and the code crashes. Does anyone know the syntax to copy the entire table, then paste it into a different document?
ms-word sas dde
ms-word sas dde
asked Jan 2 at 0:57
RABRAB
1,412418
1,412418
TryCopy
, capital C andPaste
with capital P. Those have been around for a long time, it's hard to imagine they're different. Have you checked the Excel reference for what it was then?
– Reeza
Jan 2 at 1:04
1
Also, if you're working with multiple files you may want to have specific filerefs for each, or it will be hard to know which is going where.
– Reeza
Jan 2 at 1:06
UnfortunatelyCopy
andPaste
don't work, they just crash in the same way :( I like the idea about different filerefs, once I get copy/paste to work within one document I'll definitely try and implement that. I found an Excel reference tocopy()
here: communities.sas.com/t5/SAS-Programming/…, but that also crashes so I'm not sure what is going wrong
– RAB
Jan 2 at 1:13
Do you have the parenthesis included in the command?
– Reeza
Jan 2 at 1:21
I've tried with and without the parenthasis, neither work :(
– RAB
Jan 2 at 1:25
|
show 3 more comments
TryCopy
, capital C andPaste
with capital P. Those have been around for a long time, it's hard to imagine they're different. Have you checked the Excel reference for what it was then?
– Reeza
Jan 2 at 1:04
1
Also, if you're working with multiple files you may want to have specific filerefs for each, or it will be hard to know which is going where.
– Reeza
Jan 2 at 1:06
UnfortunatelyCopy
andPaste
don't work, they just crash in the same way :( I like the idea about different filerefs, once I get copy/paste to work within one document I'll definitely try and implement that. I found an Excel reference tocopy()
here: communities.sas.com/t5/SAS-Programming/…, but that also crashes so I'm not sure what is going wrong
– RAB
Jan 2 at 1:13
Do you have the parenthesis included in the command?
– Reeza
Jan 2 at 1:21
I've tried with and without the parenthasis, neither work :(
– RAB
Jan 2 at 1:25
Try
Copy
, capital C and Paste
with capital P. Those have been around for a long time, it's hard to imagine they're different. Have you checked the Excel reference for what it was then?– Reeza
Jan 2 at 1:04
Try
Copy
, capital C and Paste
with capital P. Those have been around for a long time, it's hard to imagine they're different. Have you checked the Excel reference for what it was then?– Reeza
Jan 2 at 1:04
1
1
Also, if you're working with multiple files you may want to have specific filerefs for each, or it will be hard to know which is going where.
– Reeza
Jan 2 at 1:06
Also, if you're working with multiple files you may want to have specific filerefs for each, or it will be hard to know which is going where.
– Reeza
Jan 2 at 1:06
Unfortunately
Copy
and Paste
don't work, they just crash in the same way :( I like the idea about different filerefs, once I get copy/paste to work within one document I'll definitely try and implement that. I found an Excel reference to copy()
here: communities.sas.com/t5/SAS-Programming/…, but that also crashes so I'm not sure what is going wrong– RAB
Jan 2 at 1:13
Unfortunately
Copy
and Paste
don't work, they just crash in the same way :( I like the idea about different filerefs, once I get copy/paste to work within one document I'll definitely try and implement that. I found an Excel reference to copy()
here: communities.sas.com/t5/SAS-Programming/…, but that also crashes so I'm not sure what is going wrong– RAB
Jan 2 at 1:13
Do you have the parenthesis included in the command?
– Reeza
Jan 2 at 1:21
Do you have the parenthesis included in the command?
– Reeza
Jan 2 at 1:21
I've tried with and without the parenthasis, neither work :(
– RAB
Jan 2 at 1:25
I've tried with and without the parenthasis, neither work :(
– RAB
Jan 2 at 1:25
|
show 3 more comments
1 Answer
1
active
oldest
votes
Here is SAS 9.4M4 sample code that use experimental ODS WORD
destination to create two Word documents, and copies a table from one to the other. YMMV, and you probably have addition work regarding issues such a table wrapping and anchoring.
filename one "c:tempone.docx";
filename two "c:temptwo.docx";
ods _all_ close;
title; footnote;
options nocenter nonumber nodate;
ods word file=one;
proc print data=sashelp.class (obs=5);
proc print data=sashelp.cars (obs=5);
proc print data=sashelp.demographics (obs=5);
proc print data=sashelp.class (obs=5);
run;
ods word close;
ods word file=two;
proc print data=sashelp.cars (obs=10);
run;
ods word close;
* start WORD;
options noxsync noxwait xmin;
%sysexec start "Yada yada yada" winword;
%let rc = %sysfunc(sleep(5,1));
%put NOTE: &=rc;
* define channel for sending commands;
filename word_cmd dde 'winword|system';
* put will send the commands to WORD;
data _null_;
file word_cmd;
cmd = cats ( "[FileOpen.Name=", quote(trim(pathname("One"))), "]");
put cmd;
put '[EditBookmark name:="IDX3", goto:=1]';
put '[NextObject]';
put '[GoToNextSection]';
put '[TableSelectTable]';
put '[EditCopy]';
cmd = cats ( "[FileOpen.Name=", quote(trim(pathname("Two"))), "]");
put cmd;
put '[Selection.Goto(wdGotoLine, wdGotoLast)]';
put '[EditPaste]';
run;
The Word command ListCommands
will create a document containing a table of all the Word Commands and active key mappings.
data _null_;
file word_cmd;
put '[ListCommands]';
run;
The list goes on for 10 pages in Word 2016. Word commands are also invokable from dde connections. Unfortunately ListCommands
lists a descriptive command name, and not the command that dde actually requires, and does not actually list all commands. The WordMVP site (https://wordmvp.com) has assembled a list - "Word for Windows commands"
Word has a built-in command ListCommands, which produces a table of all the Word commands with their current key and menu assignments. However, it does not list the commands using their actual names; nor does it include descriptions of what the commands actually do.
…
WordCmndsPDF.zip contains a list of all interceptable Word commands (Word 97 and above), using their correct English names
Another reference for Word commands can be found at "Visual Basic Equivalents for WordBasic Commands", 6/13/2014.
A SAS conference paper search for "WORD DDE" will also provide additional material.
This is amazing, thank you!
– RAB
Jan 6 at 11:08
DDE will never die. (?)
– Quentin
Feb 2 at 13:25
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000150%2fcopy-and-paste-a-table-from-one-word-document-to-another-sas-dde%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is SAS 9.4M4 sample code that use experimental ODS WORD
destination to create two Word documents, and copies a table from one to the other. YMMV, and you probably have addition work regarding issues such a table wrapping and anchoring.
filename one "c:tempone.docx";
filename two "c:temptwo.docx";
ods _all_ close;
title; footnote;
options nocenter nonumber nodate;
ods word file=one;
proc print data=sashelp.class (obs=5);
proc print data=sashelp.cars (obs=5);
proc print data=sashelp.demographics (obs=5);
proc print data=sashelp.class (obs=5);
run;
ods word close;
ods word file=two;
proc print data=sashelp.cars (obs=10);
run;
ods word close;
* start WORD;
options noxsync noxwait xmin;
%sysexec start "Yada yada yada" winword;
%let rc = %sysfunc(sleep(5,1));
%put NOTE: &=rc;
* define channel for sending commands;
filename word_cmd dde 'winword|system';
* put will send the commands to WORD;
data _null_;
file word_cmd;
cmd = cats ( "[FileOpen.Name=", quote(trim(pathname("One"))), "]");
put cmd;
put '[EditBookmark name:="IDX3", goto:=1]';
put '[NextObject]';
put '[GoToNextSection]';
put '[TableSelectTable]';
put '[EditCopy]';
cmd = cats ( "[FileOpen.Name=", quote(trim(pathname("Two"))), "]");
put cmd;
put '[Selection.Goto(wdGotoLine, wdGotoLast)]';
put '[EditPaste]';
run;
The Word command ListCommands
will create a document containing a table of all the Word Commands and active key mappings.
data _null_;
file word_cmd;
put '[ListCommands]';
run;
The list goes on for 10 pages in Word 2016. Word commands are also invokable from dde connections. Unfortunately ListCommands
lists a descriptive command name, and not the command that dde actually requires, and does not actually list all commands. The WordMVP site (https://wordmvp.com) has assembled a list - "Word for Windows commands"
Word has a built-in command ListCommands, which produces a table of all the Word commands with their current key and menu assignments. However, it does not list the commands using their actual names; nor does it include descriptions of what the commands actually do.
…
WordCmndsPDF.zip contains a list of all interceptable Word commands (Word 97 and above), using their correct English names
Another reference for Word commands can be found at "Visual Basic Equivalents for WordBasic Commands", 6/13/2014.
A SAS conference paper search for "WORD DDE" will also provide additional material.
This is amazing, thank you!
– RAB
Jan 6 at 11:08
DDE will never die. (?)
– Quentin
Feb 2 at 13:25
add a comment |
Here is SAS 9.4M4 sample code that use experimental ODS WORD
destination to create two Word documents, and copies a table from one to the other. YMMV, and you probably have addition work regarding issues such a table wrapping and anchoring.
filename one "c:tempone.docx";
filename two "c:temptwo.docx";
ods _all_ close;
title; footnote;
options nocenter nonumber nodate;
ods word file=one;
proc print data=sashelp.class (obs=5);
proc print data=sashelp.cars (obs=5);
proc print data=sashelp.demographics (obs=5);
proc print data=sashelp.class (obs=5);
run;
ods word close;
ods word file=two;
proc print data=sashelp.cars (obs=10);
run;
ods word close;
* start WORD;
options noxsync noxwait xmin;
%sysexec start "Yada yada yada" winword;
%let rc = %sysfunc(sleep(5,1));
%put NOTE: &=rc;
* define channel for sending commands;
filename word_cmd dde 'winword|system';
* put will send the commands to WORD;
data _null_;
file word_cmd;
cmd = cats ( "[FileOpen.Name=", quote(trim(pathname("One"))), "]");
put cmd;
put '[EditBookmark name:="IDX3", goto:=1]';
put '[NextObject]';
put '[GoToNextSection]';
put '[TableSelectTable]';
put '[EditCopy]';
cmd = cats ( "[FileOpen.Name=", quote(trim(pathname("Two"))), "]");
put cmd;
put '[Selection.Goto(wdGotoLine, wdGotoLast)]';
put '[EditPaste]';
run;
The Word command ListCommands
will create a document containing a table of all the Word Commands and active key mappings.
data _null_;
file word_cmd;
put '[ListCommands]';
run;
The list goes on for 10 pages in Word 2016. Word commands are also invokable from dde connections. Unfortunately ListCommands
lists a descriptive command name, and not the command that dde actually requires, and does not actually list all commands. The WordMVP site (https://wordmvp.com) has assembled a list - "Word for Windows commands"
Word has a built-in command ListCommands, which produces a table of all the Word commands with their current key and menu assignments. However, it does not list the commands using their actual names; nor does it include descriptions of what the commands actually do.
…
WordCmndsPDF.zip contains a list of all interceptable Word commands (Word 97 and above), using their correct English names
Another reference for Word commands can be found at "Visual Basic Equivalents for WordBasic Commands", 6/13/2014.
A SAS conference paper search for "WORD DDE" will also provide additional material.
This is amazing, thank you!
– RAB
Jan 6 at 11:08
DDE will never die. (?)
– Quentin
Feb 2 at 13:25
add a comment |
Here is SAS 9.4M4 sample code that use experimental ODS WORD
destination to create two Word documents, and copies a table from one to the other. YMMV, and you probably have addition work regarding issues such a table wrapping and anchoring.
filename one "c:tempone.docx";
filename two "c:temptwo.docx";
ods _all_ close;
title; footnote;
options nocenter nonumber nodate;
ods word file=one;
proc print data=sashelp.class (obs=5);
proc print data=sashelp.cars (obs=5);
proc print data=sashelp.demographics (obs=5);
proc print data=sashelp.class (obs=5);
run;
ods word close;
ods word file=two;
proc print data=sashelp.cars (obs=10);
run;
ods word close;
* start WORD;
options noxsync noxwait xmin;
%sysexec start "Yada yada yada" winword;
%let rc = %sysfunc(sleep(5,1));
%put NOTE: &=rc;
* define channel for sending commands;
filename word_cmd dde 'winword|system';
* put will send the commands to WORD;
data _null_;
file word_cmd;
cmd = cats ( "[FileOpen.Name=", quote(trim(pathname("One"))), "]");
put cmd;
put '[EditBookmark name:="IDX3", goto:=1]';
put '[NextObject]';
put '[GoToNextSection]';
put '[TableSelectTable]';
put '[EditCopy]';
cmd = cats ( "[FileOpen.Name=", quote(trim(pathname("Two"))), "]");
put cmd;
put '[Selection.Goto(wdGotoLine, wdGotoLast)]';
put '[EditPaste]';
run;
The Word command ListCommands
will create a document containing a table of all the Word Commands and active key mappings.
data _null_;
file word_cmd;
put '[ListCommands]';
run;
The list goes on for 10 pages in Word 2016. Word commands are also invokable from dde connections. Unfortunately ListCommands
lists a descriptive command name, and not the command that dde actually requires, and does not actually list all commands. The WordMVP site (https://wordmvp.com) has assembled a list - "Word for Windows commands"
Word has a built-in command ListCommands, which produces a table of all the Word commands with their current key and menu assignments. However, it does not list the commands using their actual names; nor does it include descriptions of what the commands actually do.
…
WordCmndsPDF.zip contains a list of all interceptable Word commands (Word 97 and above), using their correct English names
Another reference for Word commands can be found at "Visual Basic Equivalents for WordBasic Commands", 6/13/2014.
A SAS conference paper search for "WORD DDE" will also provide additional material.
Here is SAS 9.4M4 sample code that use experimental ODS WORD
destination to create two Word documents, and copies a table from one to the other. YMMV, and you probably have addition work regarding issues such a table wrapping and anchoring.
filename one "c:tempone.docx";
filename two "c:temptwo.docx";
ods _all_ close;
title; footnote;
options nocenter nonumber nodate;
ods word file=one;
proc print data=sashelp.class (obs=5);
proc print data=sashelp.cars (obs=5);
proc print data=sashelp.demographics (obs=5);
proc print data=sashelp.class (obs=5);
run;
ods word close;
ods word file=two;
proc print data=sashelp.cars (obs=10);
run;
ods word close;
* start WORD;
options noxsync noxwait xmin;
%sysexec start "Yada yada yada" winword;
%let rc = %sysfunc(sleep(5,1));
%put NOTE: &=rc;
* define channel for sending commands;
filename word_cmd dde 'winword|system';
* put will send the commands to WORD;
data _null_;
file word_cmd;
cmd = cats ( "[FileOpen.Name=", quote(trim(pathname("One"))), "]");
put cmd;
put '[EditBookmark name:="IDX3", goto:=1]';
put '[NextObject]';
put '[GoToNextSection]';
put '[TableSelectTable]';
put '[EditCopy]';
cmd = cats ( "[FileOpen.Name=", quote(trim(pathname("Two"))), "]");
put cmd;
put '[Selection.Goto(wdGotoLine, wdGotoLast)]';
put '[EditPaste]';
run;
The Word command ListCommands
will create a document containing a table of all the Word Commands and active key mappings.
data _null_;
file word_cmd;
put '[ListCommands]';
run;
The list goes on for 10 pages in Word 2016. Word commands are also invokable from dde connections. Unfortunately ListCommands
lists a descriptive command name, and not the command that dde actually requires, and does not actually list all commands. The WordMVP site (https://wordmvp.com) has assembled a list - "Word for Windows commands"
Word has a built-in command ListCommands, which produces a table of all the Word commands with their current key and menu assignments. However, it does not list the commands using their actual names; nor does it include descriptions of what the commands actually do.
…
WordCmndsPDF.zip contains a list of all interceptable Word commands (Word 97 and above), using their correct English names
Another reference for Word commands can be found at "Visual Basic Equivalents for WordBasic Commands", 6/13/2014.
A SAS conference paper search for "WORD DDE" will also provide additional material.
answered Jan 5 at 14:21
RichardRichard
9,56221329
9,56221329
This is amazing, thank you!
– RAB
Jan 6 at 11:08
DDE will never die. (?)
– Quentin
Feb 2 at 13:25
add a comment |
This is amazing, thank you!
– RAB
Jan 6 at 11:08
DDE will never die. (?)
– Quentin
Feb 2 at 13:25
This is amazing, thank you!
– RAB
Jan 6 at 11:08
This is amazing, thank you!
– RAB
Jan 6 at 11:08
DDE will never die. (?)
– Quentin
Feb 2 at 13:25
DDE will never die. (?)
– Quentin
Feb 2 at 13:25
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000150%2fcopy-and-paste-a-table-from-one-word-document-to-another-sas-dde%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Try
Copy
, capital C andPaste
with capital P. Those have been around for a long time, it's hard to imagine they're different. Have you checked the Excel reference for what it was then?– Reeza
Jan 2 at 1:04
1
Also, if you're working with multiple files you may want to have specific filerefs for each, or it will be hard to know which is going where.
– Reeza
Jan 2 at 1:06
Unfortunately
Copy
andPaste
don't work, they just crash in the same way :( I like the idea about different filerefs, once I get copy/paste to work within one document I'll definitely try and implement that. I found an Excel reference tocopy()
here: communities.sas.com/t5/SAS-Programming/…, but that also crashes so I'm not sure what is going wrong– RAB
Jan 2 at 1:13
Do you have the parenthesis included in the command?
– Reeza
Jan 2 at 1:21
I've tried with and without the parenthasis, neither work :(
– RAB
Jan 2 at 1:25