Importing sharepoint data to excell via an existing connection through VBA - vba

first time poster here
I am looking for a specific VBA solution and I just can't seem to google my way to the exact code I need - thus, I come here
I have an excel sheet with an existing connection to a sharepoint database. It calls this connection "toolbase"
I need code so that when this sheet loads up it fills its second sheet with a dump from that connection as if I pressed the Existing Connection > Connect > import table button. Its the only known connection to the sheet.
That's it - and for the love of my feeble VBA skills then I can't find the code for this. My boss just wants a list that refreshes itself every time the file loads. I know where to put the code - I just don't what to write.
Can someone help me out?
EDIT:
The closest I could find to what I think I need is something akin to this: https://support.microsoft.com/en-us/kb/306125
but that seems to be talking about extracting records - I need the whole table

Once the data connection has been made, just have ActiveWorkbook.RefreshAll assigned when the workbook opens.
You do need to show some research effort or attempted coding in future questions though (even if it's wrong) as this is not a free coding service (i let you off this time as the answer is a one liner ^^).

Related

How to save two workbooks as and mirror the connections that they contain

I need some conceptual help from those more experienced than me --
I know you guys usually like code but I have many pages of code on this project and my question is not regarding any code I have but rather how I might code something I have not been able to figure out.
So basically I have two workbooks whose main purpose is labor tracking. one is the control workbook that has all my code, the other is a workbook where reports are made by field workers. The reason the field workbook cannot have code is because it will be operated from an ipad which I believe cannot yet run VBA. I know how to establish the connections necessary, however for every project a new copy of both the workbooks need to be made. I already have functions that clear out, reset and save the main workbook however I am struggling with the connected workbook. I know how to save the connected workbook, but I was hoping to preserve the connections between the two old workbooks when I run the macro that saves them as and also mirror those connections between the new workbooks. Is this possible or will I need clear all connections and re establish them every time a new set of job books needs to be created?
===> EDIT: I believe that I need to embed the report book into the main book, but that still begs the question on how I save the embedded workbook as at the same time I save the main workbook as in order to create a new book with all the same connections

VBA Excel lookup same value in different excel files

Would like to check the value from my master file and copy the data comments from different excel files.
In my master I have a column contained all the user name. Would like to copy the address of the user from different excel file. Would like to open the workbook and look through is the user name in the workbook, if not then then exit and open another workbook.
How should I complete the flow ?
Unfortunately StackOverflow is not a free coding service. Our goal is to help you understand how your code works and engage the community with questions that will also help others in the future. Try running some of the code on your own and see what you can come up with. There are hundreds of sources online, one of my favorite being "Excel Easy", a website that breaks down VBA coding to its simplest form. Check it out and then after you've given it a go yourself feel free to ask any specific question about your code!

Importing data from an excel sheet to a web form

I have an excel template on which I would like to validate data entered by users, and on click of a button on the spreadsheet, I'd like to get the entered information on to a 3rd party web form, which is used to keep track of the user input.
Is this possible using macros/vba for MS Excel 2010? If yes, I would like some help with the code as well...
Yes, this sort of thing is possible. Before we start giving you code, we will need to see what you have done, know what you are trying to accomplish, and what the errors are.
Because it appears that you are just getting started down the road of IE Automation here are a few websites I used initially to get started.
http://www.excely.com/excel-vba/ie-automation.shtml
http://www.makeuseof.com/tag/using-vba-to-automate-internet-explorer-sessions-from-an-excel-spreadsheet/
https://msdn.microsoft.com/en-us/library/aa752084(v=vs.85).aspx
I hope this helps you get started too.

Running a VBA excel macro at a certain time

Trying to figure out the best way to kick off an excel macro at a certain time. I found a few suggestions, but I still have plenty of questions on the idea and was hoping you guys could provide some clarification.
What I am trying to do: I have live excel workbooks that are connected to my database. So at 11:30PM on the last day of every month I want to go into several excel workbooks (I have one for every vendor that we sell), enable the security and editing and refresh the connection so all of the information in the sheets is up to date. Lastly I would like to then save a copy of that file in a sub folder inside the current folder.
Run on time method:
Here is this run on time method that I found on ozgrid. My question is, I am assuming that excel would need to be running at the time in order to execute the method? If so what would be one way of opening up excel and refreshing a workbook to be saved?
Running excel on Windows Task Scheduler Windows Task Scheduler
Essentially this method is using an Excel Controller to run excel using VBS...Seems more promising than the run on time method but I am not very familiar with how an excel controller works or VBS, so any help or ideas on this one would be greatly appreciated.
Any input is greatly appreciated. If my ideas are way out in left field could you guys help point me in the right direction?
Thanks for all the help in advance!
Turn the problem around. Create a workbook with normal Excel query tools and have it load the result set of the query when the workbook is opened (You don't specify a version, but see Refresh an external data connection for Excel 2013).
Then, either create a view in the database that contains the results you require, or to materialise the result of a view into a staging table that is then read by the workbook.
Users can then open the workbook whenever they require data, and the current results will be available. A parametrised version of the query could then access a history table to older periods.
This way all data is only prepared when required, and is always available without the scheduling complexity.

Copy Range from Form, and Paste into Workbook (preferably closed)

I have a macro-enabled form that is intended to allow of a team of data-entry staff to record their daily efforts by transaction number. As forms go, it's pretty basic. However, I need to write a macro for a button that will let each person submit their records to a master sheet at the end of their shifts. I need to copy the range data and paste to a master workbook, with the person's name and the date being added to the individual rows.
I'm not sure how to facilitate the copy and paste to a closed workbook, or how to prevent problems with multiple people submitting to the form at the same time. Can anyone offer any suggestions please?
Make it update a database and then generate the report at the end of the day from that. I would also recommend that it inserts into the database each time the user inputs a record so that in the case of a power outage, all of their work from the day doesn't get lost. This will likely reduce the amount of concurrency issues too as the users will be periodically adding records instead of many records at the same time. Search 'VBA DAO' or 'VBA ADODB' to find examples on how to connect to a database with VBA.
You can do this simply by opening the workbook, inserting, and then closing the workbook. There is no simple way to insert into a closed workbook. Note, you could keep things hidden if you're trying to hide things from the user.
Add a reference to the "Microsoft Scripting Runtime" to get access to the filesystem and then use a simple file semaphore to control access to the common workbook.
Regarding the closed workbook, you use Application.Workbooks.Open(...) and .Close
Primary Choice would be to send the items to a database. Since thats already ruled out, I would suggest you write the data to a plain old .csv file. This will be easier to implement, and will not be limited by excel row limits.