VbaProject.OTM deployment - vba

I came by this page and was thinking about the best method to distribute my VbaProject.OTM file (located into %appdata%\Microsoft\Outlook\) to a bunch of ~30 users at my office. Is it better to simply copy/paste the OTM file onto the network and then copy/paste it back to all users' computers (manually or with a .bat) OR would it be better to use the method described in the link above to generate a OPS file and import it back with Proflwiz.exe? What's the difference?
We are all on Microsoft Office Outlook 2003 actually, we might upgrade to 2007 one day but still years from now.

Finally came up with some elements to deploy a Outlook VBA Project. There are a lot of ways to do this, but the easiest way to do so without installing anything and keeping the same methodology would be to run a OTM file directly from a server. I found out that the process outlook.exe has a parameter altvba that allows to specify another path to run the OTM file from. Here is en example:
outlook.exe /altvba "\\myServer\myFolder\myFile.otm"
This allows me to update only one file to get all computers updated. Obviously, if the file is big and the server's ping is on the high side, it may delay the launch of Outlook. The other problem with this method is that everybody will have to shut down Office if you want to update the OTM file on the server (and if you do work in an office where everyone uses Outlook, you do know that it is impossible to get everyone to shut it down at the same time, except if you code a macro to do so eventually). To prevent both those problems, I could setup a batch file to copy the server OTM file clientside everytime there is a new version (just have to check the NTFS last-modify attribute). This way, Outlook will boot with a local file, the batch file take 2-3 seconds to copy the file if needed (or will launch Outlook instantaneously) and there will be no problem updating the OTM file on the server. Users will have to start Outlook with the batch file (or with the slightly different outlook.exe path with the altvba parameter, so either way they need a different shortcut/file to start off the first time). One other advantage of the altvba is that it's still easy for the user to run Outlook without it (to see if the VBA is problematic or not in case Outlook is sluggish) and the file will remain unchanged after a Outlook reinitialization.
Others solutions include a COM complement that can be developed in a lot on languages including VB6 (no conversion needed from VBA). There is also a bunch of tools included into Microsoft Office XP Developer that could help getting the job done (not free however, especially if you need the most up-to-date version).

Related

Export visual basic outlook project and add it to other outlook account

I created two macros in Outlook's VB and I want to pass them on to others where I work. Is it possible to do this without copying the code to each account individually? Is there a way to export my project (or my modules) and import it into another account so that the macros I wrote will be added automatically?
Another option for me is whether it can be done in a small program written in C# (i.e. Console Application) with the Outlook namespace.
If you're developing a solution that you intend to distribute to more than a few people, you should convert your VBA code into an Outlook COM or VSTO add-in or an Office add-in for Outlook. However, developing an add-in typically requires considerably more programming knowledge than creating a short macro. If your VBA project is relatively simple, and there aren't too many people that have to use it, you may want to distribute the code together with instructions to set it up.
The easiest solution is to right click on ThisOutlookSession and choose Export File. You'll need to do for each module (if any) in your Project.
Unlike other Microsoft Office programs, Outlook supports only one VBA project at a time. VBA macros are stored in a file that's named VbaProject.OTM. This file is a product storage file and isn't meant for distribution. Outlook doesn't provide a direct means to manage OTM files. Outlook VBA code wasn't designed to be deployed or distributed. It was designed solely to be a personal macro development environment. The project, Project1, is available and associated with the program at all times. It's not possible to add another project in the Visual Basic Editor.
Project1 is stored on your hard disk as VbaProject.otm in the following folder:
<Drive>:\Users\<LogonName>\AppData\Roaming\Microsoft\Outlook
If you want to begin a new VBA project, you could theoretically export all your existing modules and forms. But this is typically not a realistic approach. Instead, follow these steps:
Exit Outlook.
Locate your VbaProject.otm file in the indicated path.
Rename the file to something meaningful to you, such as VbaProject-testing.otm.
Restart Outlook.
Because Outlook can't find an existing project file, Visual Basic Editor starts with a new project. When you save changes to your project, Outlook creates a new VbaProject.otm file in the folder. If you want to switch between projects, add one more step to the previous procedure (as step 4):
Exit Outlook.
Locate your VbaProject.otm file.
Rename the file to something meaningful to you, such as VbaProject-testing.otm.
Restore the name the file that you now want to use as VbaProject.otm.
Restart Outlook.
If you want to move a VBA project from one computer to another, first determine where Outlook is storing the VbaProject.otm files on each computer. Then, copy the OTM file from one computer to the other, and make sure to put it into the correct folder. When you restart Outlook, the program will find the VbaProject.otm file and use it.
You may find the How to backup and save your Outlook VBA macros article helpful.

Best way for Excel workbooks to share VBA functions

I seek advice on how to manage userdefined VBA-functions that are used in several workbooks:
Background:
Over time i have created several Excel workbooks (wbs), each with a slightly different purpose, that are ultimately based on a library of my userdefined functions and class modules (From now on: library). The "master"-versions of the wbs are revision-controlled. The wbs are used by several people.
However, I do not use an addin for the library, and hence the modules and class modules are actually locally present in each wb's specific VBA project. This makes it a nightmare when doing either expansions or corrections, as I have to revisit and implement said alterations in each wb.
Furthermore, in each wb there are unique functions, understood such that those are not intended to be shared. Those functions, however, might utilize the library-functions.
Main-Question: How should one manage vba functions across several workbooks shared by several users?
My considerations/Sub questions:
Should I convert the library to a true addin and discard the local copies in each wb?
How do I tell the users that the add-in is required upon getting a copy of the maser-version?
How does one cope with legacy/local versions/branches that are spread among the users? Both current legacy copys and future legacy copies that might be used for reccuring tasks?
Where should such an addin-in be stored (in a shared folder or something)?
Would it be considered "bad practice" to force load the add-in using the workbook_opensub?
Any advice or guidance in best practice is appreciated.
Edit: I have tried to highlight the main question, please consider the sub questions as my own thoughts on the subject.
Until recently, I had several add-ins that lived on a shared drive. I had the users install the add-in using File - Options - Addins and wrote up the instructions to do it. The copy on the shared drive was read-only. For changes, I would code and test on the dev copy on my machine, then deploy it to the shared drive. The next time the user started Excel, the changes would be there.
Then we wanted more people to have the addins and not all of them had access to this shared drive. Also, people complained when they were off the network that it still tried to connect to the addins. So we went a different route.
We used a program called PDQ Deploy to put the addins in everyone's addins directory, so they had a local copy. We also deployed a script that copied the files from a company-wide shared drive to their addins directory. If they weren't connected to the nextwork, the script would fail silently. Finally, we used group policy to 1) create the registry entries to install the addins and 2) create a scheduled task that kicked off the script every night. Updating every day is overkill, but the files are only a few kbs, so we went with it.
Now I can deploy new versions to the company-wide shared drive and everyone will have the changes the next day (or the day after they're back on the network).
I put my vba stuff on the "personal" workbook (Windows menu : Unhide...) and whatever workbook I am using I can use them from there.
You do have to make sure about knowing which one is acrtive though...

Excel Macro needed which can check the downloads folder and delete all the files except the latest downloaded file

I want to make an excel file which would do the following steps:
Delete all the excel files from the downloads folder except for the one latest downloaded file.
Make a copy of that excel file names as "Data.xls" and system makes a "Beep" sound
Repeat the above mentioned two steps every 15 minutes
I can do this in Visual Basic but unable to implement that in Excel Macro...
Please help.. My promotion depends on that :-)
Set a reference to the Microsoft Scripting Runtime. The images below shows the classes available in the Object Browser. I usually use this for file-related tasks in VBA. I did some research & the Microsoft Scripting Runtime is standard on Windows so everyone should have it

What are my options to print an email to TIFF from Outlook via an addin?

We have a process at our company that processes TIFF images. I have a project where I want to be able to capture emails that people have received and let them pass it on to our imaging process. Right now forwarding an email isn't really an option but our initial thought was that we could create an Outlook addin that would create and send an image of the email to our internal webservice and it would just work.
I'm developing on Windows 7 with VS2010 and Outlook 2007.
I have the basic addin framework setup - that seems to work OK. The addin is there, popping a regular Windows form where I can do my stuff. But now I'm running into problems. First I was going leverage the built-in Microsoft Office Document Image Writer which can write to TIFFs. However, this doesn't appear to be installed as part of Office 2007 on Windows 7. Then I found some references that it didn't work on Win7 64bit in the first place, and that Microsoft was phasing it out in favor of their XPS printer anyway.
Then I moved on to thinking I could maybe use PDFCreator. This sort of works, except it looks like I have to actually have PDFCreator installed on the client machine, too. I was really hoping I could just bundle the dll and PDFCreator could natively "print", but it seems rely on you setting the active printer to "PDFCreator" and still printing to that. I was already maybe going to run into problems pushing a custom addin out to users in the first place; I don't know if I could get a new printer rolled out as a requirement, too.
On top of that, you apparently can't set the active/default printer in Outlook once it's running. So my plan to run the addin, change the default printer to PDFCreator, print it, then change it back isn't going to work after all anyway.
We really wanted to be able to capture emails as if the user had printed them out and scanned them, which is what they have to do now. I would really not like to rely on copying/pasting into another application if I can help with it.
Sooooooo, what other options might I have? Is there any close to native functionality in Windows or Office that would let me print to something and eventually get a TIFF? Does it look like I'm going to have to try and string together a bunch of 3rd party tools or something? It looks like the only way to "print" an email is to do the MailItem.PrintOut() command, which is just going to go to whatever the current default printer is. Are there any other TIFF-printing things available that wouldn't involve installing a new virtual printer on the end user's machine? Any other ideas? Thanks for any help!
Although you ruled it out at the start of the question...
Assuming you need those tiffs at a central location and not at the employee desktop.... I'd still advise you to have your addin forward the respective mail to a central location (as an attachment to a automated mail, or perhaps just write it to a queue folder on some network location), then have a central process pick it up and print it out to tiff files.
Unless you have exact control over the client machines at your company (which from the sound of it, you don't), you really want to move some fickle as 'switching printers in Outlook' away from the clients.
That doesn't mean this approach doesn't require hacks as well, because that central process will be running outlook to do the work.
I assume it is important that your tiffs look like they were actually printed from Outlook, if not please add that as extra information to your question, as it opens new routes. Like capturing the email-screen rendering and putting that inside a tiff file, which can all be done on any desktop machine.

How do I distribute updates to a Access database front end?

I've got an Access 2007 database that I developed which connects to SQL Server for the actual data storage. I used the Package Solution Wizard to create a distributable installer which included access runtime (with an ACCDE file) which I went around and installed on 15 or so PCs. Anyway, my question is, what is the best way to distribute updates to this database? Right now I'd need to go around and remove and reinstall. That's not a problem... I was just wondering if there was another way.
I've tried leaving the front end on a network share but it seems that most people suggest storing the front-end on the local machine, which makes sense. The problems I've run into when I leave it on a network share (at least with Access 2003 mdbs) is that I find myself needing to compact and repair often and I also have to kill the open sessions (user's who have the file open) when upgrading. I would imagine it could also hypothetically create an unnecessary bottleneck if the user was not on the local network.
Automating front-end distribution is trivial. It's a problem that has been solved repeatedly. Tony Toews's http://autofeupdater.com is one such solution that is extremely easy to implement and completely transparent to the end user.
We developed a vbscript 'launcher' for our access apps. That is what is linked to on the start menu of user's pcs and it does the following.
It checks a version.txt file located on a network share to see whether it contains different text to a locally stored copy
If the text is different it copies the access mdb and the new version.txt to the user's hard drive.
Finally it runs the mdb in access
In order to distribute an update to the user's pc all that is required is to change the text in version.txt on the network share.
Perhaps you can implement something similar to this
Make a batch file on the server (network drive).
Create a shortcut link to that batch file.
Copy the shortcut to User's Desktop.
When user double-clicks on shortcut, it will copy a fresh copy from network to local.
Replace old database.adp on the server drive when you update a new version.
Each user gets a copy of database.adp on their machine.
Remove Security warning when opening file from network share is here.
Batch File
#ECHO OFF
REM copy from network drive to local
xcopy "Your_Network_Drive\database.adp" "C:\User\database.adp" /Y /R /F
REM call your database file - Access 2007
"C:\Program Files\Microsoft Office\Office12\MSAccess.EXE" "C:\User\database.adp"
This is a very old post and I used the autofeupdater until it stopped working so I wrote one of my own and it has evolved over the last few years into something that I have used with many clients. It's so simple to use and there is no interface. Just an EXE and a very simple config file.
Please check it out here. I can also help with custom solutions if none of the configurations work for your needs. http://www.dafran.ca/MS-Access-Front-End-Loader.aspx
After trying all of the solutions above (not exactly these solutions but these are the common suggestions in the Access community), I developed a system entirely within Access using VBA that allows an admin DB to create and publish objects to client DBs without the need for user intervention or management of multiple DB files.
This approach has several benefits:
1. It simplifies the development process by having a dedicated environment (admin DB) for development and testing totally separate from the client DBs.
2. It simplifies the update/distribution process by allowing a developer to push out updates in real time that client DBs can implement in the background, without involving users. Can also allow devs to roll back to previous versions if desired.
3. It could be used as a kind of change management system within Access for developers who want to commit multiple changes to objects and modules and retain past changes.
4. It allows for easier user access control by allowing an admin to easily assign certain objects to specific users/roles without needing to maintain multiple versions of the DB.
I will hopefully post the code to GitHub soon, I just have to get clearance from my workplace to release it. I will edit this post to include the link when I have.
We have usually kept the Access front ends on network drives, and just put up with the need to compact and repair on a regular basis. You will probably find you need to do that even when they are installed locally, anyway.
If you must have it installed locally, there are various tools which will enable you to "push out" software updates, and the guys over on ServerFault would have more information on those. Assuming such tools aren't available, the only other option I can think of is to write a small loader program that checks the local .MDB against a master copy on the server, and re-copies it across if they are different, before then launching the MDB.