I have create Office Excel application in my machine(XP). and i have placed the application in windows server 2008 giving the following error.
Microsoft Office Excel cannot access the file '\server\Input.xls'. There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook.
both client and server systems installed office 2007 and added reference microsoftexcellibrary 12.0
created assembly for the application and calling the code from the form.
I was getting the exact same error, although in my case I was trying to run (from Tidal Enterprise Scheduler) a .NET app that used microsoft.interop.excel.
The answer is already in stackoverflow:
[Microsoft Office Excel cannot access the file 'c:\inetpub\wwwroot\Timesheet\App_Data\Template.xlsx'.
I'll re-list the steps from that link:
Create directory “C:\Windows\SysWOW64\config\systemprofile\Desktop” (for 64 bit Windows) or “C:\Windows\System32\config\systemprofile\Desktop” (for 32 bit Windows)
Set full control permissions on Desktop directory above (for example in Win7 & IIS 7 & DefaultAppPool set permissions for user “IIS AppPool\DefaultAppPool”)
Of course, if you're running a scheduled task rather than WebApp, you'll need to make sure the service account you're using has permissions on that folder.
I had the same error when trying to save to:
C:\test.xlsx
When attempting to save to the root directory, it seemed to cause problems. Changing my path to:
C:\MyExcelTests\test.xlsx
Worked fine
I would make sure no Excel processes are running on the machine before you run this application, that should cover the last point.
The first point looks the most likely issue, the path looks like a partial path or an incorrect UNC path. Try putting the full path to the spreadsheet 'C:\server\input.xls' and see if that works.
To stop the middle point, in the workbook.open command you can specify to open as read-only, this will make sure the application can red the file even if it is locked open by another user.
Related
I'm trying to move an old vb6 application from Windows 2003 to Windows 10.
There's this access reports database that is called by the vb6 app using parameters that looks like this:
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "C:\TestApp\AccessDb_ap.mdb"
/wrkgrp "C:\TestApp\AccessDb_sc.mdw"
/ini "C:\TestApp\AccessDb.ini"
/nostartup
/user some_guy
When the access db is being initialized, there's this line in some module:
sFile = SysCmd(SYSCMD_INIFILE)
The sFile is assigned "C:\TestApp\AccessDb.ini" path correctly in Win 2003 (that has Office 2003).
In the same line in Windows 10 (Office 365),
"C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" "C:\TestApp\AccessDb_ap.mdb"
/wrkgrp "C:\TestApp\AccessDb_sc.mdw"
/ini "C:\TestApp\AccessDb.ini"
/nostartup
/user some_guy
The sFile variable is assigned empty string instead of the ini path.
Is SysCmd(SYSCMD_INIFILE) not relevant anymore in Office 365 Access Db? How do I resolve this?
I wasn't able to find this information on the internet so turning to SO for help.
Thank you!
The /ini command-line switch is deprecated since Office '95 (source), and afaik completely removed since 2007 onwards.
If you want to load a specific profile, use the /profile switch and create the appropriate profile in registry.
If that command-line switch is used for something else, well, tough luck, you can't expect something that has been deprecated over 25 years ago to continue working indefinitely. You'll have to adjust the application. And while you're at it, you might want to consider that user-level security with MDW files has been shown to be easily bypassible and has also been deprecated for over 10 years
on my Windows-Terminal user, I'm trying to have two application point to the same Windows directory, one written in VBA one in VB6.
When calling the GetWindowsDirectory() API from VB6 it returns the correct path
C:\documents and settings\%user%\Windows
When calling it from VBA macro, it returns
C:\Windows
Notice that same result goes for GetSystemWindowsDirectory()
Thiking may be the VBA code wasn't aware its a Terminal station, I called the GetSystemMetrics(SM_REMOTESESSION) API which returned 1, meaning it is aware that it is a terminal.
The exact same code was used in both VB6 and VBA
Windows 2003R2 , Office version is 2010 64bit (which as i'm typing this, makes me wonder if it's related, knowing vb6 is 32bit ...)
Any ideas ?
EDIT: as explained by IInspectable below, the difference between vba and vb6 is because vb6 is not Terminal-Service-Aware like Office is.
The behavior you are observing is documented. See the Remarks section for GetWindowsDirectory:
Terminal Services: If the application is running in a Terminal Services environment, each user has a private Windows directory. There is also a shared Windows directory for the system. If the application is Terminal-Services-aware (has the IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE flag set in the image header), this function returns the path of the system Windows directory, just as the GetSystemWindowsDirectory function does. Otherwise, it retrieves the path of the private Windows directory for the user.
The DUMPBIN tool with the /HEADERS option can be used to verify, whether the IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE flag is set for a binary.
dumpbin /HEADERS WINWORD.EXE
produces the following output (Microsoft Office 2013 32-bit):
OPTIONAL HEADER VALUES
10B magic # (PE32)
...
2 subsystem (Windows GUI)
8140 DLL characteristics
Dynamic base
NX compatible
Terminal Server Aware
...
In other words: Microsoft Office is Terminal-Services-aware, and calling GetWindowsDirectory from a VBA script hosted inside Microsoft Office will return the shared Windows directory for the system.
If you checked your VB6 application with DUMPBIN, you'll see that it isn't Terminal-Services-aware, and calling GetWindowsDirectory will return the private Windows directory for the user.
Additional resources:
/TSAWARE (Create Terminal Server Aware Application)
I am having a problem with using Apache/Perl to get access to Excel files using Microsoft Data Access Component (MDAC). Somehow I must set the "CommonProgramFiles(x86)" system environment variable in order to get this to work. Otherwise, I keep getting this error message:
System.InvalidOperationException: The .Net Framework Data Providers
require Microsoft Data Access Components(MDAC). Please install
Microsoft Data Access Components(MDAC) version 2.6 or later. --->
System.IO.FileNotFoundException: Retrieving the COM class factory for
component with CLSID {2206CDB2-19C1-11D1-89E0-00C04FD7A829} failed due
to the following error: 8007007e.
The server configuration is:
Windows Server 2008 R2 in 64-bit
Server is installed with Microsoft Access Database Engine 2010
Apache 2.2.25 (that is 32-bit)
Perl 5.12.3 v5 (that is also in 32-bit)
I have my Perl CGI script to call my C# program (that is built for "Any CPU").
The C# program uses MDAC to open and read Excel files (not trying to launch Excel, only try to read data from the Excel files).
I have verified that the server has the latest MDAC available in these 2 folders:
C:\Program Files\Common Files\System\Ole DB
C:\Program Files (x86)\Common Files\System\Ole DB
I have also checked the registries and they look fine. Anyway, I don't have any problem running my C# program directly at the command prompt (it can use MDAC to get access to Excel files). I only have the problem when I use Apache/Perl to use my Perl CGI script to call my C# program (that is when I get that error with MDAC).
I can work around this problem by specifying CommonProgramFiles(x86) in my Perl CGI script, like this:
$ENV{ "CommonProgramFiles(x86)" } = "C:\\Program Files (x86)\\Common Files";
I have this question:
Why do I have this problem? And why setting that CommonProgramFiles(x86) system environment variable can workaround this problem? Why that system environment variable is empty before I set it? Does this have to do with the fact that I am running 32-bit Apache/Perl in a Windows operating system that is 64-bit?
Please help me to understand this issue. Thanks in advance.
(The original version of this post had a question about a second problem. Turned out that problem had to do with an extra double quote in the string. I fixed this, and that problem has gone away. That's why I have removed that second question from the post)
Jay Chan
I did some more research and the issue is the following: until release 2.4.9, the Apache startup routines have mapped "commonprogramfiles(x86)" to "commonprogramfiles_x86_" and that variable does not exists in the environment unless you create it... I have not tested it, but creating that environment variable and making it point to the same location as commonprogramfiles(x86) would probably fix the issue too.
Since the compiled Apache distributions are only using up to version 2.4.46 as we speak, they don't have the fix that allows the parenthesis in environment variables. That's why you still need the PassEnv directive to ensure that Apache passes the correct values to 32-bit CGI scripts.
The following post has some useful details about this:
https://bz.apache.org/bugzilla/show_bug.cgi?id=46751
I used to have the same problem in with Apache 2.4 with dBase compiled apps using ADO-32 bit as dBase is 32-bit. Something has recently changed, possibly with Windows 10 2004 20H2. I needed this fix in July-Aug 2020 but now I don't, the environment variable already exists. Since my Apache version is dated April 2020, that cannot be the reason for the change.
I tried to do some research about this but all I could find is that those environment variables are system ones existing at least since 2017, so why I needed to set this var is a mystery to me, but I would like to understand this, so if you find something, post a follow-up...
https://learn.microsoft.com/en-us/windows/deployment/usmt/usmt-recognized-environment-variables
When i try to run these .asp code https://drive.google.com/file/d/0Bx1hNT8CEtf6cUFjYlJia2JBUGM/edit?usp=sharing
i have the following error message: https://drive.google.com/file/d/0Bx1hNT8CEtf6dno3ajBpanl2OXc/edit?usp=sharing
The site is running on a Windows server 2003 64 bits, i have done a search on internet and look like is some dll missing, can i discovery what dll just with this code ?
Your file is a classic ASP file, not an ASP.NET file. Line 99 has this line of code:
Set objCrip = Server.CreateObject("Criptografia.Cripto")
Criptografia is usually the name of the DLL and Cripto is the name of the object inside of it. You can perform a search on your hard drive for Criptografia to see if it exists or search your Registry for the full name Criptografia.Cripto to see if there is a different DLL associated with it.
My application works like this,
1. The Office 2007 Excel Add-in reads information from the App.Config file.
2. Uses that information to various purposes within the application.
I have got a strange problem in Win7 64 bit and Office 2010 32 bit/64 bit machines when this add-in is deployed. There is no need to create a new add-in for Office 2010 as your Office 2007 add-in will be compatible there.
The configuration file is not read and there is no information to use and so the application fails subsequently. This happens in deployment scenario alone.
Please refer to the attached sample add-in which is created closely to my requirement.
1. You need to have a file C:\Test.log before running this project. This will save some information as log.
2. Build the project and build the setup project seperately. The setup file will be available in ${proj_folder}\ExcelAddInSetupProject\Debug.
3. In debug mode things will work fine. On installing the setup file, the configuration file will not be read.
4. Specifically the following codes are not working.
string[] names = ConfigurationManager.AppSettings.GetValues("Name");
if (names != null && names.Length > 0)
{
name = names[0];
}
or
string un = System.Configuration.ConfigurationSettings.AppSettings["Name"];
Can you please let me know why this happens? Is there any fix for this?
The code that use for getting config strings from the app.config is:
string value = ConfigurationManager.AppSettings.Get(keyName);
The only other thing is to make sure that the app.config is in the same project as the adddin but not under the Excel section.