Connect from Excel to Access database on internet server - excel

I hope someone is able to help me out with the following. Currently I have an excel based tool that is able to retrieve and upload data (via ADO) to an Access database. This works perfectly fine, but now I need to use it on a server that is to be approached via Internet. Running the macro does not work any more where it is giving me a run time error: 'Your network access was interrupted'. I use the following connection string:
pad = ActiveWorkbook.Path
xdatabase = pad & "\Rolling forecast Database.accdb"
stDB = xdatabase
stConn = "Provider=Microsoft.ACE.OLEDB.12.0;" _
& "Data Source=" & stDB & ";"
Although I see that people encounter the same problem I am not sure what it is that causes the macro not to function properly any more. It has to do with the fact that the server is probably not local? Any solutions for this problem?
Grateful for your swift response,
Cheers Michiel

You could use HiveLink (https://hivelink.io) to do this..
It would basically turn your spreadsheet into a live service and you would need a computer running all the time with have your original spreadsheet. HiveLink would help you create a "lightweight" spreadsheet that your users can use anywhere, which doesn't have any macros or calculations. A person using it would authenticate themselves, enter their input data, press a macro button and the inputs would be sent to your "master" spreadsheet. HiveLink would run the macro you choose in the master spreadsheet, which could be your Access database upload or whatever, then it would send back any results you want your user to have. The connection string would stay only in your master spreadsheet. End users don't need to install anything, but it only works in Excel (2010+) for Windows, and they would need to enable macros for it to work.

Thanks for your reaction guys. I solved it by using a local server! Cheers

Related

Running SAS programs from excel

I have a few SAS programs that I need to run from excel. The programs pull tables from SQL, perfom some calculations and give an output table that I would like to present in Excel. So I figured that it would be great to run everything in excel.
There are a few parameters in the code that need to be changed before running, so the best idea I had is to put the SAS scripts in cells on an excel sheet and change the variables with VBA.
My question is, is this achievable? Can I connect to SAS and do everything from excel?
I'm fairly good with VBA, starting to learn SAS, but I don't really know how to connect the two. Thank you for your help!
Yes it is possible , i did this in my work a week ago , SAS have an documentation here?
The link below can help you.
http://documentation.sas.com/api/docsets/itechwcdg/9.4/content/itechwcdg.pdf?locale=en
You can use ADODB to connect to , see here for the strings
https://www.connectionstrings.com/sas/
Your options are:
1) use VBA to connect to IOM, create a workspace, run your program.
This requires quite a bit of VBA, as well as the SAS Addin for MSO, and various components.
2) Run a Stored Process (STP) via point and click using the MSO addin
Again, this requires a desktop SAS Addin deployment, and isn't scriptable with VBA
3) Run a Stored Process as a web query
This is an excellent option - you don't need any special desktop installation, you can easily add (url) parameters, you can use it with / without VBA, and your output will render easily into your worksheet so long as you stream tab delimited data via the _webout fileref (without %stpxxx macros). It will also work with all versions of excel and SAS.
This approach is described here: https://www.rawsas.com/sas-as-a-service-an-easy-way-to-get-sas-into-excel-power-bi-and-000s-of-other-tools-languages/

Excel ,VBA, PowerPivot, DataFeed connection - update path to file

I am trying to preapare excel file which would download data from many sources with one button.
Sadly, this file would be used by people, which have not any shared folder or something, i cant connect datafeed file in place where they all can access it.
This connection is created in PowerPivot.
Thats why i am trying to prepare macro, which would update path to file for each user.
How i can update this path with vba?
I am able to get current path by using
Debug.print Activeworkbook.Connections(1).Datafeedconnection.Connection
But i cant update this which using
Activeworkbook.Connections(1).Datafeedconnection.Connection = "..."
It dont work with puting the result of debug.print with small changes, also it dont work when i am trying set this connection to something like = "Test"
If it's needed, i would give exact result of debug.print when i get access to this file (probably tomorrow), but maybe if i am doing something wrong (like choosing wrong command), you can help me before that?
With little help from another place i found solution for this problem.
When i am creating connection with PowerPivot, i am not able to edit datefeedconnection.connection property (it returns error 1004).
However, when the connection is created in excel directly i am able to update this by command:
Activeworkbook.Connections(1).Datafeedconnection.Connection = "..."
To create connection in excel directly, we have to go into:
- Data tab
- Existing connnection
- Browse for more (bottom left corner of box)
- Choose your .atomsvc file

Excel 2016 cannot access DDE server

I'm using Excel 2016 to access a DDE server (Rockwell Software's RSLinx Classic.) The DDE server is working correctly/can be accessed from other applications. The problem is trying to access it from Excel.
This is what is in my cell: =RSLinx|PS9TOPIC1!'N7:0'
The PS9TPIC1 topic is set up (and works) in RSLinx. RSLinx is up and running. But I get:
Remote data not accessible... Start application RSLINX.EXE?
Clicking Yes gets:
Cannot run 'RSLINX.EXE'. The program or one of its components is missing or corrupted
The program runs fine. I have ensured that RSLinx.exe is on the PATH (Double-checked the PATH for the running Excel using Task Manager.) It doesn't matter whether I have RSLinx running before starting Excel or have Excel try to launch it.
No, the option to "Ignore other applications that use Dynamic Data Exchange" is not checked for this document.
I tried running both RSLinx and Excel as "Administrator" with the same result.
Bringing up the help for data connections shows this:
Note: In an earlier version of Excel, you might have used Dynamic Data Exchange (DDE) in combination with the Step-by-Step Mail Merge Wizard in Word. Excel no longer supports DDE. If you'd like us to consider this feature for the next version of Excel, drop us a comment in the Excel Suggestion Box.
Try using an older Excel license.
I had the same problem, i already solved it. Just go to your project in the kepserver, open properties, and make sure enable the DDE conection to your server... Just that in my case. Good luck..
enter image description here

Set A Connection String In Excel To A Cell Value

I'm creating a workbook for some folks to be able to manipulate some data, get blessings from all involved, then hand off to someone else to manually enter back into the system... Don't ask, we are afraid of scripting back to the system.
I am attempting to do this in the Data Connections Properties Window.
Data > Connections > Properties > Definition (I can't attach a screen shot cause I'm a noob I guess)
I have many different work arounds. I have even created a VB script that will do this, allow users to change server targets, pass different security credentials, but, just this last Monday there was some kind of office patch that screwed up all activeX and I had to go wipe out a temp file to correct it. I can't do that with a bunch of users that are less than tech savvy that are geographically separated, I don't have RDP authority.
For example, the connection string currently looks like:
DRIVER={iSeries Access ODBC Driver};
System=myserver.network.net;
I was hoping to set it to look like:
DRIVER={iSeries Access ODBC Driver};
System="Overview!D9";
The cell, Overview!D9, could then be changed by who ever to the correct system string, like myserver.network.net or server1.network.net.
Near as I can tell from my research, the connection properties window is pretty cut and dry and this might not be possible. But figured I would ask around.
Assuming System is just a string, then getting the value is simple.
' Assuming System is a String
Dim System As String
System = ThisWorkbook.Worksheets("Overview").Range("D9").Value
If System is part of another string, its much the same
' Get the value to use in the connection string
Dim System As String
System = ThisWorkbook.Worksheets("Overview").Range("D9").Value
Dim ConnectionString As String
ConnectionString = "DRIVER={iSeries Access ODBC Driver}; SYSTEM=" & System & ";"
If security is a problem, and your people generating/manipulating the data don't NEED the macros to do their work (ie, just the person entering the data back into the system does) then you don't need to put the macros in their workbooks.
You can add your macro's to the "Default Workbook" on the data entry person's computer. These macros will then be available to all workbooks they open on their computer.
Your data entry person gets the benefit of scripted automation and your users don't have to worry about email or anti-virus problems.

Excel VBA - Password prompt after Form Show and Import Data

I have this macro that is password protected and shows a form. Recently I added code to import data from excel and every time I close it asks me for a password - I can cancel through it but I'd like to make it go away, I see no plausible reason why it would come.
I've separated out the few lines that causes this problem
Sub a()
UserForm1.Show
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0" & _
";Data Source=" & "C:\Book1.xls" & _
";Extended Properties='Excel 8.0; IMEX=1'" & _
";Persist Security Info=False"
Set objRSGlobal = CreateObject("ADODB.Recordset")
objRSGlobal.Open "select * from [Sheet1$]", strConnString
objRSGlobal.Close
Set objRSGlobal = Nothing
End Sub
This goes into Module1. I have a blank form called UserForm1. I lock the code (for viewing as well) using a password and save everything in Book1.xls.
Now I open the file, do an Alt+F8 to run the macro, close the form and then close the file the password prompt comes up. I can't understand why it comes up and how to make it go away.
Thanks in advance!!
Note - for the record, this also happens if I just show the form and do an Import Data via the UI (Data > Import External Data > Import Data)
Update - it looks like its happening only when I import from the same file I have open.
This looks like the problem described in Microsoft Knowledge Base Article KB280454
http://support.microsoft.com/kb/280454
I encountered this problem working with .NET and COM interop. The article advises ensuring COM references are released. I was unable to do this successfully in my case. I tried delegating commands from Excel to a non-VBA-password protected workbook which reduced the occurrence and finally set up a process to kill my app (with Xtreme Prejudice, using a second process). Neither of these seem appropriate in the case of this question but a similar kludge may be required.
http://www.officekb.com/Uwe/Forum.aspx/excel-prog/40862/VBA-project-does-not-close-when-workbook-is-closed
looks like a google desktop issue.
I had the same issue, and it is related to the Excel/Jet queries from open Excel Workbooks (including the current workbook). The following Microsoft kb article describes the problem.
The issue seems to be fixed in Excel 2010, although that did not help me (as my clients are still using Excel 2007). One way to do it is to save the data into another workbook, query it there and then copy the result back in to the original workbook, but that is a bit cumbersome.

Resources