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

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

Related

Insert Hyperlink in Access Database (pyodbc)

Here is the situation: I'm 'having fun' really using Microsoft Access for the first time for small personnal project/tools ideas.
I don't know anything about VBA yet, and unless I can't do without it, I don't plan to learn it this time (already a lot else to cover).
So I tried to use Python to automatize the main table filling. I did find pyodbc package and succeeded to connect, read and write some data out of my database.
However, I wanted to experiment a little further, and one of the fields could contain hyperlinks (could be handled somewhere else in another script later, but I am curious about the functionality anyway)...
But I couldn't figure how to insert hyperlink data in the table. I only get the displayed text set, but not the target one.
Is this feasible using pyodbc or am I on the wrong track?
Thanks in advance!
Emmanuel
The hyperlink field in MS Access consists of three parts, separated by #:
display text # filename or target # location within the document
So an example of the data of a field can look like this:
StackOverflow#http://www.stackoverflow.com#
See the docs: https://learn.microsoft.com/en-us/office/vba/api/access.application.hyperlinkpart
and samples here also: http://allenbrowne.com/casu-09.html

Unable to determine why workbook gets marked as read only when opening another workbook via VBA

Background: I can't seem to find an answer for the blunder I've found myself in. I'm working on a dashboard of sorts for our organization that pulls data from different workbooks in different locations. Different people have different permissions within folders in our company. We're trying to prevent having to change permissions. I was also trying to make it easy as possible for employees by moving the necessary supporting files I pull from to my folder where the dashboard is housed that includes a folder with the supporting files. Since this folder has no restricted access, I added passwords to the whole workbook of each supporting file. I created workbooks in the original locations of where these supporting files used to reside with the hopes that would hopefully allow anyone with access in that folder to use this new file as a backdoor/shortcut of sorts. The goal was to keep people's files where they wanted them and allow them to click it then it takes them to my support file and enter the password for them. Which leads me to the problem...
Problem: When I open the "backdoor" file, everything runs normally and the support file opens up with read and write privileges. However when someone else opens the backdoor file, the support file opens as read only. While I don't have any code yet to determine if someone is in the file (I'll cross that road if my problem is resolvable), I've ensured nobody was in the support or backdoor file when another user attempted to use it.
Sub Workbook_Open()
'I didn't have the next statement orginally. Added it in hopes it'd resolve the issue.
'Tried to move it under the workbooks.open command, too, but to no avail.
SetAttr "M:\Report Writing\Supporting Files\TMR 2017 - Team ABC's SF.xlsm", vbNormal
Workbooks.Open "M:\Report Writing\Supporting Files\TMR 2017 - Team ABC's SF.xlsm", , False, , "XXX"
Workbooks("TMR 2017 - Team ABC's.xlsm").Close
End Sub
I also didn't originally have the "False" in the open.workbooks command but tried to add it in hopes of resolving my dilemma. Any hope is GREATLY appreciated as my whole dashboard is relying on this and we were supposed to deploy today.
It has nothing to do with the VBA code. It is the file itself. On a shared network, depending on how it was set up, when a new file is created everyone can read it, but only the creator is marked as the only one allowed to make changes. If someone Saves the file with another name you wont be able to edit it. You created the file, you can make changes to it.
There is a way to change this. Right click on the file, properties, security, Edit Button, There are some listed users in there but just find the one that says Drive\Users or Authenticated Users, or both, and edit that to provide modify access. This will allow everyone to edit the file.

Batch file for inserting macro's

I am trying to create a batch file as icon on desktop, that would open a specific excel file, create a macro in it and copy code from a specific txt file into it.
The reason i need this, is that the file is located on a server and the ending .xlm cannot be cahanged (should not) so i cannot save it as a macro enabled file (to store a macro in it )
Could annyone with better understanding please explain to me how to create the said code ?
Thanks in advance!
In theory it's possible by using the VBE object (https://msdn.microsoft.com/en-us/library/aa443984%28v=vs.60%29.aspx). But that's not activated by default so you can not ensure that each user is able to do that.
Better find other solutions for that problem. Can you upload .XLSB for example? Or do you have another kind of server available - for example a database server - you can use for storing the file? We use this method here for deploying our updates on AddIns and report templates for example.

Programmatically change crystal rpt connection

I'm trying to find a way to Programmatically change the connection string of an rpt file permanently to a connection that currently doesn't exist. I need to send these rpt reports out to clients who are using a different connection then I am.
I've tried some examples where you load the report and then set the connection with apply logon info, but it seemed to only affect the report at run time and the changes never stayed. I need the rpt file to keep the connection string i set.
Is there an way to do this?
You need to call the method SaveAs of the ReportDocument class.
If you need to change just one file you can use this tool instead of writing your own code: http://www.r-tag.com/Pages/CRDataSource.aspx
The free version works for one file without restrictions.

ssis excel source cannot acquire connection manager at DESIGN time

I have an SSIS (super)package that consists of several (about) 40 packages, each of which has several data flow tasks, most of them loading some excel data to a sqlserver database. So I have several excel source connection managers, one per excel file.
This has always worked fine until recently : I have to change an excel source in one of my packages (a column was added in the excel which has to be loaded in the destination sqlserver table) but I cannot edit the excel source in SSIS : when I click on "columns" I get an error box "DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER". So this is a design time issue, not a run time problem. I've seen a question like this one on stackoverflow but no answer. Anyone has an idea ?
I' ve already removed office 2007 and reinstalled office 2003 on my machine, but this didn't help
it has nothing to do with 64bit mode, which I've read about here
Is there some limit on the number of connection managers in ssis ?
Most of my connection managers were created with copy/paste and hence they have the same Id, although they point to different excel files. Could this be a problem ?
I should also mention that the package runs without any problems, so it's only "editing/changing" the package that doesn't work. For the moment I circumvent this problem by disabling the data flow that should change and by replacing it with a sql statement that hardcoded inserts the data from the excel into the destination table.
Maybe another intersting thing to mention : I can create a new package and add and change excel sources without problems, but then again, when I try to copy this excel source in my package, I cannot edit it.
Did you try to check the advanced options on the Source Connection?
Right click on the component and select "Show Advanced Editor..."
Select the column mappings tab and press the Refresh button.
This should point out that the XLS connection has some additional columns or that the file that you are pointing at, cannot be pre-validated at runtime.
M.
I'm not sure if this will work but try the Work Offline option in the SSIS menu in BIDS/VS. What this should do is not validate the connection before you edit the component. It might be able to get you into the component.

Resources