function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
OnDem DevOnDem Dev 

Opening Word Document from Scontrol

Hi,

 

I need help in finding a solution of opening a Word Document from SControl.

Let me explain the scenario.

Word Document is uploaded as an Attachment to Salesforce system. 

 

Now my requirement is that when i click a View button in my Scontrol, i have to retrieve the content of Word Doc attachment and modify some values in that content.

Then this modified word doc content should be opened as a Word Document from the SControl.

 

So what should be done to achieve this.

 

Any help on this will be highly appreciated.

 

Thanks,

OnDem

Best Answer chosen by Admin (Salesforce Developers) 
KeithJKeithJ
Fantastic Idea! Im going to do just that :)

All Answers

lamayclamayc

Since I doubt you will get any responses here, I will write something that seems reasonable but I cannot guarantee it is correct (like that?)

 

Anyway, Word "doc" format is a proprietary microsoft format that has LOTS of stuff in it (i.e. it is not just simple ASCII text, it is a binary format). I believe there is a whole API that you have to use to access it. In other words, it is not easy. Take a look at this How do I... Modify Word documents using C#? article(http://blogs.techrepublic.com.com/howdoi/?p=190.)  (Maybe you can use other languages too?) Aside from that, even if you could open the document, you are still limited to what Apex can do (which is nothing with a Word document, nothing with binary stream especially, blah, blah, blah.)

 

Suffice is to say, if it has to be a Word document, the only thing I could think of is to read the info in the above link to create a modification program and then create a web service to have your control send the document to. Have the web service modify it and then send the updated document back to salesforce.

werewolfwerewolf

Why not just redirect your window (or pop up a window) that opens the doc just as if you had clicked the View link on the attachment?  For instance,

 

https://na1.salesforce.com/servlet/servlet.FileDownload?file=00P30000001oDhw

 

(where 00P30000001oDhw is the ID of my attachment).

KeithJKeithJ
Fantastic Idea! Im going to do just that :)
This was selected as the best answer