BookmarkSubscribeRSS Feed
gupta_shubham
Obsidian | Level 7

I am working with EXCEL AMO. In the AMO I want to create a button which could open the PDF report from SAS library (or SAS generated report in any other format).

That's why I want to write a SAS code which could open a pre-generated report.

x "path/abc.pdf";  is one possible option to open a pdf file from SAS code but this code does not work in SAS AMO

10 REPLIES 10
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, assuming the AMO means the SAS Office plugin, I would assume that your "button" would be an office one and that you would need to use VBA to open something.

Have a look at: Open PDF file in Excel with VBA - Stack Overflow

gupta_shubham
Obsidian | Level 7

Well to my best knowledge I think that I can't use VBA to access SAS Library of Metadata server

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Is it not just a network path?  If not write your reports to somewhere accessible.  Afraid I don't use this so can't help further.

gupta_shubham
Obsidian | Level 7

Thanks for your reply.

I really don't know much about AMO. I just started using it recently. But if leave excel out of the picture then just consider the case where I want to open a PDF report using SAS code. Is is possible somehow ?

In simple words what I am trying to ask is: Is there any alternative of following statement in SAS ?

x "path/report.pdf"

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Not that I know of.  A PDF is a proprietary format, normally binary.  It requires a reader to open and parse the information, and then to render it.  What you are doing with the X command is actually loading and exe file provided by Adobe with a parameter to your file.  That software then opens and renders the contents. Its not actually Excel or SAS, just need a way of running the reader exe and being able to pass a network location/filename in as a parameter to that exe, somthing like

"c:\adobe\acrobat.exe" "\\network\temp\your_file.pdf"

gupta_shubham
Obsidian | Level 7

You are right about it.

Basically x "\\network\temp\your_file.pdf" this code would also works in Windows as it just asks the windows to open the pdf file location at the path(through shell). But since I have to link this code to Excel and Excel doesn't allow me to use "x" commands.

That is why I was asking a alternative to "x" statement.

Cynthia_sas
SAS Super FREQ

Hi:
Normally, if I go to Excel and do a simple File --> Open, I cannot just open a PDF file (see screen shot). So adding SAS to the mix is not going to change the fundamental nature of Excel. By default, when you run stored processes (for example), every client application (such as AMO) can only "receive" certain kinds of stored process results. Excel, for example, can only "accept" CSV, HTML and SASReport XML output from a stored process. PowerPoint, for example, can ONLY read SASReport XML. Word can receive RTF, HTML and SASReport XML from a stored process.

So I am not sure that an X command will help you with what you want to do.

cynthia


excel_not_open_pdf.png
gupta_shubham
Obsidian | Level 7

Hi Cynthia,

Thanks for your reply. Information provided by you is helpful but I think I didn't explain my doubt properly. What I want is to implement a button in Excel which could open pre-generated reports(pdf, html, rtf-anything would work for me) from SAS defined library. I know that PDF file can not be open using excel as browser. I don't care whether these reports gets opened in excel or their particular browser (e.g Adobe reader for pdf, Word for rtf etc). I just want that on clicking this button should open reports which are located in predefined sas library in any browser (let say chrome for html or adobe reader for pdf). That is why I was trying to use 'x' statement to open a pdf file from SAS.

Cynthia_sas
SAS Super FREQ

Hi:

  The only files you can access from a "SAS defined library" are SAS datasets and files, like catalog files. Although you can open pre-defined SAS Report files, those do NOT include PDF, RTF or other files that are intended to be opened by 3rd party applications. The idea of making a "button" in Excel is more of a VB/VBA/.NET concept than a SAS concept. You can pull data from SAS into Excel, because data in SAS libraries is defined in the metadata --and there are already buttons on the Add-in ribbon that allow you to open or point to SAS data files. Then, there is a Reports button that allows you to run a stored process. But as far as putting a button inside Excel to open ANY kind of file, including RTF and PDF seems to me to be an Excel automation question and not a SAS question.

cynthia

SASKiwi
PROC Star

Its my understanding that the SAS AMO interface is designed to surface SAS content into the Microsoft tool it is being called from, so rows and columns into Excel, text-style reports into Word, XML-based reports into Powerpoint, not to display other content "on the side".

In other words you are trying to do something with AMO that it was never designed to do. If you are simply wanting a SAS tool that will interface with pre-generated reports, then I suggest you look at SAS Web Report Studio. 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 10 replies
  • 2053 views
  • 3 likes
  • 4 in conversation