Reply
Goin' WAY up the ladder here
Old 10-07-2007, 05:35 PM Goin' WAY up the ladder here
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Okay, here's the question:

I'm generating a Word doc on the fly with ASP. I've pretty well figured out everything that I want to do, exceeeeeeeept...for embedding a header image. I want to embed a logo on the header of each page, but can't figure out how for the life of me.

NOTE: because this is going on a shared server and not my own, plugins/custom components are not an option. So whatever I do has to be purely code.

Any ideas? Thanks.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
When You Register, These Ads Go Away!
     
Old 10-07-2007, 05:48 PM Re: Goin' WAY up the ladder here
chrishirst's Avatar
Super Moderator

Posts: 11,495
Location: Blackpool. UK
You can create the document in HTML the save it as a .doc
Code:
    Response.AppendHeader("Content-Type", "application/msword")
    Response.AppendHeader ("Content-disposition", _
                           "attachment; filename=filename.doc")
    Response.Write(docBody)
and you can download the Office HTML and XML Reference which tells you all you need to know about those mso-normal bits and pieces.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-07-2007, 06:08 PM Re: Goin' WAY up the ladder here
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Yeah, I had the first part figured out (saving the .doc). It was the MSO normal thing I've never really been familiar with. Guess I'll have to learn it.

Thanks, dude.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 10-07-2007, 11:05 PM Re: Goin' WAY up the ladder here
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Okay, before I rip my hair out, I need some more help (how rare is THAT?)
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<?XML-stylesheet type="text/css" href="CSS/xml-renewal.css"?>
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:o="http://schemas.microsoft.com/office/word/2003/wordml">
  <w:docPr>
  <w:view w:val="print"/>
  <w:zoom w:percent="100"/>
  <w:proofState w:spelling="clean" w:grammar="clean"/>
</w:docPr>
<w:body>
<div class="Section2">
<p class="MsoNormal">Dear <strong>Joe Smith</strong>:</p>
</div>
</w:body>
</w:wordDocument>
I must be missing something painfully obvious...but every time I save this as a Word doc, it turns up completely blank. I get all the pages, but each page contains a series of carriage return characters and no text. And I want to use the XML to set the print view, because by default, the web view shows up.

So...how do I get the stuff to actually appear?

It's not the CSS (it works.)
It's not the XML itself (since it works too.)
It's not the Section2 div (I've changed this twice).

I'm not sure what else I'm missing.

Last edited by ADAM Web Design : 10-07-2007 at 11:14 PM.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 10-08-2007, 01:23 PM Re: Goin' WAY up the ladder here
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Never mind. I just figured out what I was doing wrong (another case of 1,000,000 answers, one correct one, and finding the needle in the haystack.)

But I got it now.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 10-08-2007, 01:58 PM Re: Goin' WAY up the ladder here
Learning Newbie's Avatar
Moderator

Latest Blog Post:
Dick Cheney as a Web Comic
Posts: 4,622
Name: John Alexander
I don't get it. In ASP.NET this would take 15 lines of code. Create an instance of the WordDocument object, add it's content, then write it to a file or to the Response object. Why would you do this in ASP Old SchooL? That's like hand cuffing your ankles together and running a marathon. I know you already have more experience than Moses in ASP but you can link to an ASP.NET page that runs under the same IIS site and then from that page you can take advantage of all the modern stuff. The good thing about using the OfficeDocument sub classes is they live in the GAC so when Microsoft goes and changes things, you won't need any code changes to stay up to date. If you hard code the format, and it gets subject to change, you have to change all your generating code.
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 10-08-2007, 04:17 PM Re: Goin' WAY up the ladder here
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Actually, in this case it wasn't ASP that was the problem at all...it was Word specifically, or to put it more accurately the lack of accurate documentation around Word's version of XML. I'm reminded of when I first tried to learn ASP about 7 years ago...it was the same level of frustration.

The reason I won't go to .NET is simply because I have too much stuff compiled in ASP that wouldn't port over. I wrote it by myself, for myself.

I don't wanna learn anymore either. My brain's too full.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 10-08-2007, 05:41 PM Re: Goin' WAY up the ladder here
Learning Newbie's Avatar
Moderator

Latest Blog Post:
Dick Cheney as a Web Comic
Posts: 4,622
Name: John Alexander
That's what I'm trying to say. The OfficeDocument abstract class has an intimate knowledge of the XML formats they've used in Microsoft Office. You can save to Word 2002, Word 2003, or even the bloated html from Word 97. The .NET objects tap directly into the Microsoft Office interoperability framework - what Word uses, but also what the free Word Viewer uses for people to open Word docs in read-only mode. When Microsoft changes this or adds a new format, the core Office Interop DLLs get pushed down to the machine in a Windows Update.

By using the .NET libraries, you'll always be using the proper version and formatting for whatever XML variety is for the Office product you want to target. I'm pushing you for this situation because I had to upgrade an ASP page that made Excel files using OLE Automation to use the proper methods in ASP.NET now. The old one was really finicky and fragile, but the new one just works. You can't imagine how relieved I was. I wish my good friends could or would take advantage of the same great time and stress saver I was so happy with.

Also, I think there are two misunderstandings. Even tho you got it fixed anyway, this is just for future reference
  1. You don't have to convert everything to ASP.NET to take advantage of its wonderfulness. You can just drop one ASP.NET page into a web site with all ASP pages and the server just runs each of them the right way. Kind of like how you can use HTML (static) pages in an ASP site, and IIS knows which ones to serve, and which ones to parse first.
  2. You could always run the code conversion wizard to take all of your ASP pages and let the system build ASP.NET pages for you. I did this once, too, in a site with about 350 pages. I didn't think automatic generator tools worked, but the transition was seamless. And the company was thrilled at how much faster the site ran from DLL files on the same hardware! I know you're not gonna do that, and maybe in Canadaland you don't have to? But it's an option on the table.
There's really a lot of stuff in ASP.NET that a bright, creative guy like you could take advantage of. Even without having to change a line of your existing code - just tapping into the new stuff on an as needed basis.

I must sound like a Cult of Mac person. But you know me well enough that I wouldn't be advocating a programming foundation unless I really strongly thought the person I was talking to could benefit from it. In your case, you're thinking like it's 2601 but programming like it's 1899.
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 10-09-2007, 12:04 AM Re: Goin' WAY up the ladder here
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,025
Name: Forrest Croce
Location: Seattle, WA
Are you sure? I've never heard of any of the Office software having apis to build new files in .net? I don't use Office much these days, but I've always gone with the same kind of stuff Adam is doing.
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 10-09-2007, 12:11 AM Re: Goin' WAY up the ladder here
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
John: there will be a time I'll learn ASP.NET. But, like most people, it'll happen when I'm forced to learn it.

As of right now, I'm not forced.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 10-09-2007, 12:38 PM Re: Goin' WAY up the ladder here
Learning Newbie's Avatar
Moderator

Latest Blog Post:
Dick Cheney as a Web Comic
Posts: 4,622
Name: John Alexander
Out of curiosity what means forced? A job that requires it? Cause for me it's when it becomes easier to learn a new technology than to mold one I already know around a situation.

I ask because there are dufuses who read a 1200 page book and then do exactly what everybody else is doing, and there are people who come up with clever spam filters.
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 10-09-2007, 01:27 PM Re: Goin' WAY up the ladder here
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Precisely, John. When I have a job that requires me to know it, then I'll learn it. I'll just need the syntax, since I'll have the application.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to Goin' WAY up the ladder here
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.17798 seconds with 13 queries