I have written a VBA macro in Excel that references a .dll library (COM-interface) located in a UNC path (\\SERVERNAME\FOLDER).
Unfortunately my company started blocking the use of dll-files in "untrusted locations" in Office, which includes all UNC paths (using Sophos).
Is there any easy way that I can create a .dll that simply references/redirects to the original .dll?
Related
I have created a file structure within Microsoft Teams to support a sales forecasting tool. VBA routines access and modify these files as appropriate. I would like to check if a file exists in a target directory before attempting to open it and then handle any missing files within VBA. I cannot find a way of doing something analogous to the Dir instruction, e.g.
If Len(Dir("c:\Filename.xlsx")) = 0 Then Msgbox "This file does NOT exist."
Substituting the URL returns error 52 "Bad file name".
Opening and saving files works fine, but if the file is not present, I only get a system error which I cannot handle within my environment.
If you sync the files locally, you can go on with Dir and local path instead of url.
I have an Access application that VBA references to Microsoft ActiveX Data Objects but I find that the path to the msado28.tlb type library is wrong (point to a network location!!!).
I found a PC that it does not have problem and the correct path is C:\Program Files (x86)\Common Files\System\ado\msado28.tlb.
I tried to point to this location but nothing happened!!
The pc's have Windows 7.
Recently I made an application that has lots of PDF files in it and I made a setup for it using Inno Setup Compiler. In the setup, I allowed people to change where they want to install the app. For opening my PDF files, I used: system.diagnostics.process.start("My pdf.pdf")
My problem is that in the code above, I put drive "C:" and when my user changed the install directory to drive "D:" the pdf's did not work and the error showed that "Cannot find the specific file". My question is that is there a way to just put the name of "computer" or "a drive" in the code above, not the specific name of the pdf, and let the computer find the file itself?
You seem to be asking for an opposite of what you actually want to achieve.
I assume you are installing files with known names. What you do not know is the directory of the files.
From your description I assume that your actual code is like:
System.Diagnostics.Process.Start("C:\My pdf.pdf")
But when the user chooses a different location (directory) for your application, the above code with a hard-coded absolute path fails.
If your application installs to the same directory as the PDFs, just use a relative path (in this case just a file name without any path). It makes an operating system look to the current working directory, which will typically be an application directory.
System.Diagnostics.Process.Start("My pdf.pdf")
Or to make it more reliable, make it explicitly look to the application directory. For that use Application.StartupPath:
System.Diagnostics.Process.Start(
System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "My pdf.pdf"))
See also Get program path in VB.NET?
I have a macro that I developed in Word 2010.
How do I send this to others to use?
From the sublime to the ridiculous, here are four different options:
Create an add-in. Distribute and tell others to install it. Instructions
Create a COM add-in. Distribute and tell others to set a reference to it. Instructions
Export the code module containing your macro to a *.bas file. (Right-click module, Export File...) Distribute and tell others to import it.
Copy-paste macro code into an e-mail. Distribute and tell others to paste it into a module.
Save the document as .dotm (macro enabled template). Save it to
%Appdata%/Microsoft/word/startup
Close word. Now, it will be accessible to all other word documents.
If not by default, then go to templates and tick the file saved above
to deploy, create a simple script that copies the file to the appropriate folder. You can probably deploy via email
Go to the VBA Editor.
Open the Project Explorer if it is not visible (View>ProjectExplorer or Ctrl+R).
If a new module is needed in the project for your file (Project ( _your file_ )),
right click on the project and select Insert>Module
OR select the project, then on the menu, select Insert>Module.
In the Project Explorer, open Project ( your file )>Modules>ModuleX.
Copy your code into this module.
Save the file as a Word Macro-Enabled Document (*.docm) (File>Save or Ctrl+S).
Distribute the file. The code will now go with it.
I used an old solution - Nullsoft Scriptable Install System to copy the .dotm file to the %Appdata%/Microsoft/word/startup directory. To do this, I set InstallDir in the NSIS script to this:
InstallDir "$APPDATA\Microsoft\Word\Startup"
NSIS creates a small installer in the form of an EXE file that is easy to distribute and easy for users to install.
I am using Scott Mitchell's textBox Characters and Words counter control, i downloaded it from the website https://web.archive.org/web/20211020202742/https://www.4guysfromrolla.com/ and unzipped it to my desktop. then in VWD Express 2008, i created a new tab in the Toolbox, i chose the *.dll from the unzipped folder, i used the control, all is fine (try it, i recommend it) but when i backed up my code, copied the site, and tried to run it on another computer, i got a bunch of error all indicating that its looking for the dll file on my desktop, but when i checked under my bin folder in my website directory, the dll is there...
Help Plz...
If you view the properties of the reference you'll probably find that the path to the reference is incorrect.
I have often found that the quickest way of fixing the problem is to open the project file with notepad and correct the path to the reference.