BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
texasmfp
Lapis Lazuli | Level 10

I have a SAS program that prepares data and then pours data into an Excel file.  This is followed by a macro that goes in and "pretties it up" such as changing fonts, column widths etc.  I want to add a new function, tell Excel to copy one column an paste it back to the same place, but as values - which is Paste Special rather than the regular paste.  In Excel macro language, the language is:

 

Columns("L:L").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

 

But when I try to make that run in a SAS DDE session, along with the other prettying up, it does not work.  I've done some trial and error, but I just don't know enough about translating Excel-speak to DDE-speak.

 

Can you tell Excel to special paste or is this a lost cause?

if tab EQ 'Unit Value Series' then do;
put '[select("c12")]';
  put '[copy()]';
  put '[SELECT("c12")]';
  put '[xlPasteValues()]';
  end ;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
texasmfp
Lapis Lazuli | Level 10

Kurt:

 

I created a VBA script in Excel and then added a put line to call that script in the long cue of formatting in the "prettyup" macro.

 

 put '[workbook.activate("Unit Value Series")]';
  put '[run("macro4")]';

 

Thanks

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

DDE is deprecated by Microsoft. The ports have been taken over by other software, causing DDE to not work at all. Even if you could make it work now, you only take out a loan at the future.

 

Use ODS to build the Excel completely with all styles, or prepare a VBA script which you can run as an external command.

texasmfp
Lapis Lazuli | Level 10

Kurt:  thanks, but I am working on an isolated system with Office 2016.  Works great and no need to change at this time.  I'd appreciate help with the issue rather than a suggestion to abandon hundreds of lines of code and start from scratch.

texasmfp
Lapis Lazuli | Level 10

Kurt:

 

I created a VBA script in Excel and then added a put line to call that script in the long cue of formatting in the "prettyup" macro.

 

 put '[workbook.activate("Unit Value Series")]';
  put '[run("macro4")]';

 

Thanks

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 380 views
  • 0 likes
  • 2 in conversation