VBA Excel: Transfer to Word and Access - vba

I have a program in VBA excel that manipulates data and transfers it to a few different sheets. What I would like to do now is transfer one sheet to Microsoft Access and one sheet to Microsoft Word. I would like to keep all of the code in my excel VBA workbook if possible, as opposed to Access or Word.
I want the sheet named "Data" transferred to Word and "Points" transferred to Access. I want the code to transfer these sheets to uncreated documents, then name the documents and save it. Each sheet can be transferred individually.
I have tried looking up answers to this question but have failed to find any good information! I have little idea where to begin with this specific code, so any help would be greatly appreciated.

Your question asks for to much. Books on Excel VBA like "Excel 2013 Power Programming with VBA (Mr. Spreadsheet's Bookshelf)" will help.
I will say that it will be easier for Access to pull the data from excel using it's own VBA code. To send data to word int he way you describe, will involve initialising a new word application and a new document.
Get a book, it will pay for itself as this sort of situation is often described.
Try google searche for:
"linking to excel data in an access application"
Also see:
http://www.mrexcel.com/forum/excel-questions/698670-using-excel-visual-basic-applications-export-data-ms-access-table.html
https://www.youtube.com/watch?v=PhpZQw1ktP4
And Youtube channel ExcelisFun.
Harvey

Related

Is there a way to tell the pasted content source in Word VBA?

I know that MS Word allows users to choose how they want the paste to be depending on whether the pasting is from another software or same document or a different document. Is it possible to obtain that content source information from VBA? Thanks!
If you want to get information about a source of data in the clipboard, comming form outside application - sorry, it's impossible.
MSDN wrote:
The clipboard is a set of functions and messages that enable
applications to transfer data. Because all applications have access to
the clipboard, data can be easily transferred between applications or
within an application.
The function to get such of information does NOT exist!
Note: that VBA can get some information via OleAutomation (COM):
This overview does not describe how to copy and paste linked or
embedded objects. For information on these subjects, see the Component
Object Model (COM) documentation.
More information about VBA + Clipboard you can find here: Visual Basic for Applications/Clipboard VBA

Exporting Excel files from SAP with pivot tables

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.

How to extract data from a database and populate a sheet in Excel

I am storing data in a backend database (PostgreSQL) which is running on a Linux machine. I want to be able to fetch data from the database, and populate a sheet in an excel workbook, so that I can carry out analysis in Excel.
It has been quite a while since I wrote anything in VBA, so I would appreciate some help (or links) in getting started. I would like to know the best way to approach this:
Pure VBA solution OR
Mixture of C# or other .Net language for data extraction logic and VBA for manipulating Excel objects (sheet data population etc)
Any ideas, tips, snippets and/or links that can help me get started on the twin objectives:
fetching data from a backend database (PostgreSQL) into Excel
populating a specified sheet in Excel with the columnar data retreived from the database
will be much appreciated.
If you are just trying to import data, Excel can do that without additional code. Just set up your windows client to connect to your postgreSQL server thru ODBC. (Here's one way guide to setting that part up: enter link description here
Then in Excel (Use a modern version, like 2007 or greater) from the "Data" tab, click on "Existing Connections" to connect to the ODBC connection you set up and pick the tables/data to import into excel. Once the spreadsheet has loaded the data, you can just click the "Refresh All" button to update the data.

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.