Exporting Excel files from SAP with pivot tables - vba

I currently have a report which will be emailed to business users weekly. The data output can only be csv/xml and I do not have the ability to automatically add the requested pivot tables; therefore, I am attempting to pull the data with a Workbook_Open sub routine in an Excel file I will have premade. My issue here is I cannot use Macros on SharePoint nor can the Data be publicly accessed in a Macro...so I feel like I am up a creek.
Any suggestions from a VBA, Excel, or BEX/BOBJ standpoint?

Well if your report is forced to be csv/xml.... and you can't access the data directly through a macro... the solution is not terribly straight forward.
Here is how I would solve
1) SAP Job drops off file
2) Some type of automation kicks off a macro
3) Macro formats and emails report
probably possible to have sap email a spreadsheet formatted to taste directly via abap code.... that is not something i have much experience with.

Related

Implementing cell protection in SAS

I create stored processes for my business partners to execute via SAS E.G. / Add-in for Microsoft Excel (AMO). My business partners generally execute a report I've written in SAS E.G. through Excel where they can view the data on-demand versus waiting for my team to provide it.
This generally works out great, but there is a new requirement I'm trying to satisfy and I'm not entirely sure how to go about resolving it. The management of my business partners has asked that we protect/lock the cells that the data is output to. The output is predictable, so I can use something like R1C1:R70C3 to protect the sheet.
I believe this can be done using DDE, but I'm not entirely sure. The users would be connected to our server at work via their SAS metadata profile which I believe would have an impact. Admittedly, I'm not that familiar with DDE, but basically I'm just trying to lock a row/column combo each time the program is execute.
Here's code that I can use through Excel, I'm just not sure how to integrate this into my SAS program.
Sub ProtectActiveSheet()
Worksheets("Sheet1").Protect UserInterfaceOnly:=True
End Sub

Link Data Models to multiple files

I created a file that imports multiple tables, and then I do several modifications and calculations with Power Pivot. The problem is that I want to use the final results, not only in that current workbook, but also in other workbooks.
So my question is, is there a way to link other excel files to that data model that I created and worked on?
Please note the data changes every day, so I am looking for a permanent connection.
Appreciate any help here.
if I understand you correctly you would like to access the PowerPivot model/measures that you have created in one xls file from within other xls files.
If so, the "core" vs. "thin" workbook approach might be what you are looking for. This approach works with Excel 2010 but not with Excel 2013 however and you will need a Sharepoint Server with PowerPivot for this to work.
The approach is described in Rob Collie's awesome PowerPivot blog:
http://www.powerpivotpro.com/2011/02/powerpivot-scheduled-refresh-pt-3-thin-workbooks/
and here:
https://pivotstreamllc.zendesk.com/hc/en-us/articles/201148566-Splitting-Workbooks-into-Core-Thin-Pairs
another option is to load all your data source in one Master workbook, then write back the result in the same workbook using Reverse Linked Tables.
Now you can use that Master workbook as your backend for all your reports.
or use PowerBI Desktop as your backend, officially it is not support but Excel can have a local connection to PowerBI desktop.
I put more details here
https://datamonkeysite.com/2016/11/13/thin-and-core-workbook-without-sharepoint-or-ssas/

Creating Spreadsheet from SQL using ASP - Can I attach macros?

So I have been using ASP for all of a week now and perhaps this is something that I just can't do, but I am trying to dynamically generate reports from data stored in a SQL database. I am publishing the reports through an ASP document and displaying by specifying Excel for the MIME content type:
Response.Buffer = TRUE
Response.ContentType = "application/vnd.ms-excel"
Is it at all possible to "attach" macros to the document? I understand I can do basic formatting in the HTML, but I would prefer to import the desired database data and handle it within excel via macros.
EDIT:
I have several reports I need to generate but for one example:
I want to load retrieved data from the database into a sheet in excel.
Attach Macro
Begin Macro:
Hide the specified sheet.
Programatically create new sheets for categories of data.
Format sheets.
The question is not about how to program the macro, just whether or not a macro can be attached and how to achieve this. In regards to alerts upon opening the sheet, if I can attach macros I should, theoretically, be able to suppress those in the Open Workbook event.
EDIT: I believe I can achieve the desired result by using OWC (Office Web Components) (see http://support.microsoft.com/default.aspx?scid=kb;EN-US;288130). However, I am not sure if I will be able to install it on our Web Server. Any other suggestions?
While it is possible in a strictly technical sense, it is neither simple nor advisable. The recipient of the sheet will get multiple prompts related to the security of your macros; the source of your macros; and if they really, truly, honestly meant to click to enable macros...

Dump MS Access Macro object info from VBA code

I have a project in which I need to compare different versions of an Access 2003 database against each other. We're not interested in the data in the tables. We're only interested in the objects that describe the database. I.e. Form objects, Report objects, QueryDefs, TableDefs etc.. The databases are fairly large so the approach is to dump all the descriptions for objects of interest into a text file by running a VBA app in each of the databases and then comparing the results in a diff viewer.
I've been looking around for several days to find out how to dynamically dump access 2003 macro content from within VBA. Please don't confuse this with dumping VBA code from VBA.
I know about Application.CurrentDB.AllMacros to get a list of macros in the active access database. But I can't get at the macro object from Macro(MacroName).SomeProperty because the macro isn't open. So I've been trying to look for a way to open the macro and haven't found a way to accomplish this through VBA.
Any help on the topic would be appreciated.
Thanks!
You can export macros with the undocument Application.SaveAsText:
Application.SaveAsText acMacro ,"AutoKeys", "AutoKeys.txt"
...saves the AutoKeys macro to whatever the current directory is.
You could manually ask Access to convert the macros to VBA. There is an option for that, I think when you right click the macro. After that you can compare the generated VBA.
See the following page for a list of utilities to compare Access databases
http://www.granite.ab.ca/access/thirdparty.htm

Exporting Excel cell data to database via Excel macro?

Can I create a macro written in C# for Excel that allows me to export a cell's data to a SQL Server or Access database?
Basically, I'd like to create a button in Excel that saves the data in certain cells to a database. Can this be done?
Instead of creating a UI from scratch for a program, I've decided using Excel as the user environment would be better for business needs.
How to automate Excel by using Visual C# to fill or to obtain data in a range by using arrays would be a good starting point.
Be aware, you're going to find it frustrating to control what people attempt to enter into the Excel sheet, as the inherit flexibility of the data works again your efforts to write it to a database destination.