we are working with Delphi 7, SQL server 2008 and MS word 2003. now we are planning to migrate MS word 2003 to MS word 2016.
in our application we will load the document(BLOB field) from database and save it into .tmp file and then we will open the document using TOleContainer in Delphi7.
above process is working fine for .doc and it is not working for .docx. we are able to replicate the issue with below example
create the .docx file
open .docx file and enter some text and save and close
rename the .docx to .tmp
open the .tmp file using TOleContainer(Below Delphi code)
Delphi Code:
procedure TForm1.FormShow(Sender: TObject);
begin
WordOleContainer.AllowInPlace := True;
WordOleContainer.CreateObjectFromFile('F:\WordViewerTest\docx.tmp', False);
end;
when we run the application we are getting below error.if we click on open document is getting opened in another window, not in olecontainer.
if i double click on .tmp file, it is opening with out any warning.
if i use the above delphi code it is showing warning. how to make above code work?
So long as *.docx file is actually a *.zip file from a binary point of view, there's no way to distinguish for the OLE binary pattern class search mechanism (described in the GetClassFile reference, step 2. of determining strategy) between those file types. If you registered a binary pattern for *.docx file, you would actually register *.zip files for opening by an application of your choice. Since then all the programs using OleCreateFromFile would open *.zip files in the application you've registered.
So to resolve your problem without any ambiguity in the system simply save the file with the proper *.docx extension and let OLE find the class by the file extension (step 3. of determining strategy).
Related
I'm developing application for converting DWG to PDF. Developing on Delphi using AutoCAD OLE. The best solution I found it's using Publish command. It work OK, but the problem is when I open DWG file some messages can appear. For a example, it can be missing SHX files message, or remember file was created in an earlier version, about ObjectARX and so on. Of course these messages appear when manually opening these DWG in AutoCAD.
But, for a example, when using Excel via OLE it has silent mode, so no messages will appear.
Is any similar in AutoCAD?
There is some system variables like FILEDIA or EXPERT (I use it) but it available only in document, when it opened already, not for application.
Here is a part of my code, where I open DWG:
...
CoInitializeEx(nil, 0);
AutoCAD := GetActiveOleObject('AutoCAD.Application');//connect to running AutoCAD
if not VarIsNull(AutoCAD) then
begin
cadDocument := AutoCAD.Documents.Open(InputFilename, True);//here's problem line code
...
end;
...
i want to import exe file into my delphi application resources.
and then extract and run the exe.
my qustion is:
how can i:
Import exe file into my resources
Extract exe file into "c:\" (with SaveToFile function)
Run (Shell exeFilePath) the exe.
See this answer for an example how to include an file as a resource to your app. The example there is for a text file but it is the same idea for the exe file. It also shows you how to load that resource into an TResourceStream and then you just use it's SaveToFile method to save the exe to the disc. Once you have the exe on the disc you can run it with ie CreateProcess.
there are component libraries allow you tou store your file on the from, inside DFMs
For example if installed JediVCL you can drop the TJvDataEmbedded component onto the TDataModule or TForm and load a file into it. Then in the runtime you can extract that file onto disk or into TMemoryStream.
About running - the most simple thing would be to call ShellExecute function - read your Delphi help about it. Or you can use the class from Jedi CodeLib which allow you a lot of customizations. But you probably do not need it.
I have a delphi project that somehow has become corrupted. I upgraded to Advantage 11.1 components (using XE) and now I'm getting the following error message when opening the project:
acctTbl: Error 5018: The handle given was not recognized by
Advantage. Verify specified handle is open/active. The given handle
is not recognized as a valid Advantage Client Engine
Because the error occurs, the data module DFM is not built, so I can't "adjust" any settings.
acctTbl is the first table in the DFM, so the error might occur for the ones following, but I can't tell.
We are not using the server, just the "Local Server".
I have tried to go back to version 10 of the components, but still the error continues.
I have also tried removing all of the projects object code and only opening the PAS and DFM files (by reverting from SVN).
Any help is greatly appreciated.
You can open the .dfm in a text editor (like Notepad), and change the AdsConnection.Connected property to false, and change any AdsTable or ADSQuery component's Active flags to false as well. (I'd suggest closing the IDE first, to make sure it doesn't cache a reference.) This will at least let you open the project and make whatever changes are needed to compile with the new version of ADS.
If the file has been updated through many older versions of Delphi prior to XE, there's a chance you still have a binary format .dfm file (meaning you'll see all kinds of strange symbols in Notepad when you open the .dfm file). If that's the case, Delphi includes a conversion utility (convert.exe, found in your $(DELPHI)\Bin folder), and you can use the following steps to convert it to text format and then make the changes (there's no need to convert it back after - the default is to create text .dfm files when new forms are created, and Delphi uses them very well as text).
Make a backup copy of your datamodule's .DFM somewhere safe first!
After making the backup copy, open a command window in your project folder, and run
Convert.exe -1 YourDataModule.dfm
The command says to convert in place (-i), which means the existing binary .dfm is overwritten by the new text .dfm (and the reason I stressed making a backup copy first). If you don't want to overwrite, you can omit the -i switch, and it will create a YourDataModule.txt file in the folder instead; you can then manually rename YourDataModule.dfm to a different name, and then rename YourDataModule.txt to YourDataModule.dfm.
I am trying to save (compress) a .zip file using JclCompression with the JCL Demo. When I press the Save button on the Read and Write Tab the demo calls:
procedure TFormMain.ActionSaveExecute(Sender: TObject);
begin
(FArchive as TJclCompressArchive).Compress;
CloseArchive;
end;
When (FArchive as TJclCompressArchive).Compress; is executed it produces an exception: "At least one compression volumes could not be replaced after an archive out-of-place update." Also sometimes when I press the save button, the "application is not responding" appears in the form's caption, so I have to shutdown the demo.
Is this code correct or do I have to change it to sucessfully compress and save the zip file? Are there any other demos for JclCompression so I can learn how to use these classes?
Aside from this problem the demo seems to be working correctly. I can open a zip file, create a new zip file, add files, add files from a directory, extract selected files, extract all, and get zip file properties. Saving seems to be a problem.
I am using Delphi 2010 on Windows 7.
Same issue as jedi-jcl-compression-library-wont-open-spanned-archive-files.
JEDI JCL Compression library wont open spanned archive files
The JCL-JVCL version you use is buggy.
I would recommand to upgrade your JCL installation to latest daily build
I saw this error message when files which I wanted to archive were opened for writing, so you need to close them or copy them to temp folder in advance. Also If you using function Create7zArchive() as i do you need 7z.dll placed in your bin output folder. It's sad, but it seems JCL doesn't use Zlib.pas which is already integrated in Delphi.
JCL 2.7.0.5676 (Stable)
I am testing one application that handles files (stored in SQL Server using FILESTREAM). It is a Delphi 32bit application.
Opening an XLS document stored in the database (originally saved with Office 2003) gives an error from Excel 2010 64bit. Is there some known compatibility issue of Office 2010 64bit with 32bit applications?
Error messages and workflow
When opening the file Excel gives one of the following error messages:
Impossible to open the file FILE because of problems in contents
Impossible to open the file because some parts are missing or not valid
Opening a file on machine A with Office 2007 opens the file with no problems. Opening the same file on machine B with Office 2010 produces the error message. Opening again on machine A there is also an error message! In all these steps I am just reading from the database, not writing. So why does this can happen?
How do I open the documents?
SELECT query to get 'DOCUMENT' varbinary(max) field for the specific ID_Document.
Extract from database using
TBlobField(sqlQuery.FieldByName('DOCUMENT')).SaveToFile(sDestinationPath + FileUniqueName + .zip');
Copy file from one path to another using Windows.CopyFile
Unzip file using TZipforge component
Set attribute of unzipped file to ROM using FileSetReadOnly function.
Open document using ShellExecute(0, 'open', PWideChar(FIleName), '', '', SW_SHOWNORMAL);
As you can see there is nothing that writes back to the database. Once the file is extracted from TBlobField it is even copied to another place before unzipping and opening it.
Possibly broken installation
Office has been reinstalled and now everything works, the problem of corruption was due to a conflict with an open Office installation that asked "do you want to fix the office installation?". Anyway the problem still remains, because I cannot understand what happened. How can I corrupt a file in the database if I extract it in a folder and open it from the folder without writing anything back to database?
Office 2010 64-bit should have no problems with files created with its 32-bit version. The files (.docx, .xls) are bitness independant.
I have some questions:
How do you open your files?
Can you show some code?
Are you sure that you are only reading the file from the database?
Do you give your files the right extension? Saving a .xls as .xlsx will cause problems when opening the file.
Check if your SQL server database is corrupt. Check disk where database is for errors. Reinstall SQL server.
Solved: it was a bug in my program. There was an error in the logic that persisted the document status and by mistake sometimes Is_File_Compressed was set to False, even if it is true.
Thanks for the support.