Different letters for shared drives - vba

Quick Background: I write excel macros for a company that uses shared drives on the network to share information between employees
The Problem: Different employees have the same shared drive listed under separate letters. For example Susie has the "Commissions Shared Drive" as drive "Z" but Betty has it as drive "x".
I'll design a macro that two different people use and the macro runs into errors because they have separate drive letters. To put it simply, the file locations written in the code won't be correct for both people due to the difference of drive letter.
The Current Solution: I currently have a copy of the exact same macro with changes made to the file locations to account for the difference of drive letter. This is annoying because anytime I make changes to the one file I have to ensure the other is exactly the same.
The Question: Is there a way I can account for different drive letters in one macro so I don't have to have duplicates of the file with different addresses?
Thanks in Advance!
-Mike

Use the actual network path.
For instance instead of something like
Z:\filename
Use
\\servername\foldername\filename
As long as the user has access to the path, the code will find it regardless of drive mapping.
Edit:
You can view this question and its answers for some great reasons why you should not use the mapped drive letters in your code.
As a side note, if you were using something less updatable then an Excel macro, it would be a good idea to not actually store the path in your code at all. Instead you would have a file that the code views to obtain the path. Thereby what you write will work far longer without having to be recompiled or revised. But again, since you're just doing an Excel macro I see no compelling reason not to use the direct path.

#Daniel Cook I also found another path that you can use to refer to a shared drive.
If you right click on the shared drive and go to properties > DFS (DFS is a tab in the properties window) they list a separate path there that works. I created a macro to test both paths and both worked.
However, one of my associates said he made a macro for another employee using the path method of \servername\foldername\filename and it didn't work on her computer for some reason, but when he used the other pathway found in the DFS tab under the shared drive's properties it worked for her.
Any ideas why the \servername\foldername\filename path might work on one computer and not another?

Related

How to make an ImageList of a folder from the internet?

I have looked everywhere for the answer but couldn't find it. What I am trying to do is take a folder of Google Drive and put it into my image list. The folder is a shared folder so I am uncertain if I can just use the Google Drive folder on my computer that is used for syncing to my Drive.
Accordingly to the comment posted by #jmcilhinney.
This is a classic case of a question that needs more focus, i.e. it's
really a combination of multiple questions. Creating and populating an
ImageList is the same no matter where the images come from. Your
question is whether multiple machines can see the same cloud drive,
which probably doesn't even have anything to do with VB.NET or
programming at all. If you can map that folder locally on two machines
then you have your answer about whether multiple users can see the
same folder. If you can access any file in that folder in VB.NET then
you know that your app can do that. That's it done.

Accessing External Modules

I have about 8 different workbooks that all have the same modules in them. Unfortunately, the workbooks need to be separate. I have four modules in each workbook. Whenever someone finds a problem with the workbook such as an error I did not catch originally in the code, I have to make the correction to all of the workbooks. Presently, I make the correction in one of the modules, export it, and then delete the bad module from the other workbooks and import the corrected module(s). This is time consuming and I am hoping to find a way to either quickly import the updated modules or access the modules from a centralized location on the network drive. Is this possible?
I have scoured the internet but either I am not typing in the correct search or no one seems to have this issue. Thanks
If all of these workbooks reside on your machine and are used mostly by you, then you could put the macros in your personal.xls file and have only one copy on any of the various spreadsheets. There's a good tutorial about the personal.xls on Ron de Briun's site:
http://www.rondebruin.nl/win/personal.htm
Part of your question suggests that the workbooks might reside on other computers and you are then updating and distributing the new versions. If that is the case you might try using the method suggested by Charles Williams in this Stack Overflow question:
How to get VBA excel addin .xlam to replace itself by a remote updated .xlam?
Then you would simply create a shared add-in and replace the file in one location referenced by the xla/xlam. Ozgrid has a decent primer on creating add-ins:
http://www.ozgrid.com/VBA/excel-add-in-create.htm
Hope that at least some of this helps with your problem.

Find evey open MS Access instance/file

I've had an ongoing neglected question on Expert's Exchange that I would love to finally have answered. Here's the link:
My Expert's Exchange question
My objective is to return a list of every Access file that the user has open at any one time. The site includes a complete set of code to retrieve all open Excel and Word files as an array of those application objects. I've tried everything I know to solve this problem and am poised to pay Microsoft Tech Support to help me answer this question, if no one on the forums is forthcoming with an answer.
The solutions you link for Excel and Word function by looking for instances of those programs running, and using their known COM interface to find the files they have open.
With Access, other things can open the files as well. For example, a C# program or SQL Server import wizard could also have the files open.
A general solution would be rather tricky. However, if you can be sure that the files have the usual extensions, you could enumerate all files that are open in the system and return a list of those that have an appropriate file extension.
To enumerate all open files in the system, see the EnumerateOpenedFiles() method in this article
http://www.codeproject.com/KB/shell/OpenedFileFinder.aspx?fid=422864&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=26&select=2277170
Note that you don't need all of the code there, as it presents a shell extension that calls EnumerateOpenedFiles() as part of it's operation. You only need that one method, modified to return only files matching the desired file extensions.

Comparison of files of two folders

I want to compare files of two folders in vb.net with respect of date time and size and put the odd ones in two list boxes for each folder. I am not getting through the logic. Can any one of you help me with logic or code?
Thank you.
Get the FileInfo for each file in each of the directories.
Compare the required properties of each.
Consider what to do if there are files in one directory which are not in the other.
Question scope is too wide to be covered on StackOverflow.
However, there is an open source project called DirComp.NET.
It looks like a good starting point for you.
DirComp.NET is a simple command-line tool written in VB.NET, which compares two directories, and either lists differences or mirrors one directory onto another. For example, it can be used to backup large file repository by maintaining a mirror copy. It lives well with existing Windows infrastructure, which already provides file shares. And finally, DirComp.NET is based on .NET Framework 2.0, which is available from Windows 2000 and up.

Is there a way to change user desktop directory path value in Cocoa?

I know there is NSDesktopDirectory that will get me the path to current user desktop directory, but where is this path value written and is there a way to change it from my cocoa application I cannot find out.
Can anyone point me in the right direction?
Additional explanation: in Snow Leopard when I rename Desktop folder to anything whatsoever, the content of this folder still shows on desktop, so I guess OS keeps track about that folder name and locations changes and keep it as desktop folder. Does anyone know how it does that?
One way you could do this is by storing whole set of files from the user's desktop (including .DS_Store, which has positional/spatial information) into a folder in your ~/Library/Application Support/ folder, then moving other files on the ~/Desktop? This should effectively "replace" the user's desktop.
[Posted as an answer as suggested above]
I spent about 40 minutes researching this out of curiosity. Google is unhelpful in this particular scenario so I poked around my ~/Library folder. The path isn't stored anywhere there. I then dug around with command-line-fu to check flags and any other metadata I could find. Nothing helpful.
I think this is a built-in thing that uses file system references as opposed to hard-coded file paths (which is why its "Desktop" designation survives renaming). If you delete it, it creates a new one and stores the ref to that one. You'll not be able to swap it around.
I think Phil's comment is probably your best bet: move the contents of the folder rather than the folder itself. Here's my take on it:
~/Desktop/.myDesktop1 ... ~/Desktop/.myDesktop2 ... ~/Desktop/.myDesktop3
Perhaps even: ~/Desktop/.myappdesktops/1 ~/Desktop/.myappdesktops/2 ~/Desktop/.myappdesktops/3
If you move stuff into a dot-folder, it'll remain hidden but there. Active stuff stays in ~/Desktop as normal but each of your conceptual "Desktops" gets stored in a dot-file so it stays hidden.
Caveat: Time Machine. :-) Regardless of your approach, swapping out "sets" of files will potentially wreak havoc with any backup solution.
So, to answer my own question: there is no way to change the desktop path in Snow Leopard or Lion (although you van read it). The only way to switch dasktops is moving the contents itself which can be done with a set of AppleScripts to some degree :(.
The other way is this app here :)):
http://itunes.apple.com/us/app/projectdesktops/id499870251?ls=1&mt=12