How to add MSWord file in delphi 7 project directory
Asked Answered
C

1

5

I want to add MS Word file in my delphi 7 project directory.I already have created resource file (.rc) and include Word file in it.But when I am compiling .rc with BRCC32, it shows [Error] RLINK32: Unsupported 16bit resource in file "C:\Program Files (x86)\Borland\Delphi7\Projects\stuff.rc". What I have to do?

Cisneros answered 24/12, 2012 at 8:7 Comment(2)
And please also show how you compile the .rc file, and how you link the .res file.Whitherward
if you don't change word file often you can also just embed it into DFM. That is a bit easier to use in runtime, but if your word file keeps changing - then better to let it remain separate file and link via RCPlanospore
W
7

The error message indicates that you are attempting to link the resource script, the .rc file, rather than the compiled resource, the .res file.

So you presumably have a line that reads:

{$R stuff.rc}

This instead should read

{$R stuff.res}

What's more, judging from the error message, I suspect that you resource script, the .rc file, is not a resource script. I bet that it is in fact a Word document.

Your .rc file needs to be a text file that looks like this:

WordDocument RCDATA MyDoc.doc

You also need to compile your script. Like this:

brcc32 stuff.rc

This compilation step produces the binary compiled resource file, the .res file.


To make it crystal clear, you need to carry out these steps:

  1. Make the .rc file as described above.
  2. Compile the .rc file with brcc32.
  3. Link the compiled resource by adding {$R stuff.res} to one of your Delphi source files.

You need to go back to basics and try to understand Windows resources better.

Whitherward answered 24/12, 2012 at 8:27 Comment(7)
now i again make .rc file which contain text 'WordDocument RCDATA C:\Program Files (x86)\Borland\Delphi7\Projects\stuff.docx'.But when give command brcc32 stuff.rc in command prompt.It shows ERROR COULD NOT OPEN INPUT FILE stuff.rc.Cisneros
You can work this out for yourself. The error message reads "COULD NOT OPEN INPUT FILE stuff.rc". So, you check that the file exists. If it does then how could it not be opened? Most likely reason is that your working directory is wrong. What is your working dir when you run brcc32? Is it "C:\Program Files (x86)\Borland\Delphi7\Projects"? If not, that's your reason. Change working dir and try again.Whitherward
More advice. Do not put the full path to the file in the .rc file. Make your .rc file just like the one in the answer: WordDocument RCDATA stuff.docx and rely on using relative paths.Whitherward
You are absolutely right. My project directory is wrong.Now its working.Cisneros
If you add {$R 'stuff.res' 'stuff.rc' } the IDE will automatically compile the rc for you. (Quotes around file name are because you can have paths/names with space in there, also you can use relative paths: {$R 'some_icon.res' '..\..\General\Shared\Resources\some_icon.rc'} As of D2010 (I think), don't put a path with the .res as the ide now has settings where it outputs the res files.Latrishalatry
@Marjan Is that so even in D7? I was not sure.Whitherward
Ah, missed the D7 bit. Don't know about D7 (don't have it), D5 certainly doesn't.Latrishalatry

© 2022 - 2024 — McMap. All rights reserved.