IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Re: Requesting advice on how to do this
I have collection letters program that dumps data into a word document using Find & Replace. In the form letter are place holders for the data, such as <CUSTOMER_INFO> <LATE_INVOICES> and so on. Also within the form letter are 2 macros:

Sub FindReplace(pFind As String, pReplace As String)\n    Selection.Find.ClearFormatting\n    Selection.Find.Replacement.ClearFormatting\n    With Selection.Find\n        .Text = pFind\n        .Replacement.Text = pReplace\n        .Forward = True\n        .Wrap = wdFindContinue\n        .Format = False\n        .MatchCase = False\n        .MatchWholeWord = False\n        .MatchWildcards = False\n        .MatchSoundsLike = False\n        .MatchAllWordForms = False\n    End With\n    Selection.Find.Execute Replace:=wdReplaceAll\nEnd Sub\n\n\nSub Find(pFind As String)\n    Selection.Find.ClearFormatting\n    With Selection.Find\n        .Text = pFind\n        .Replacement.Text = ""\n        .Forward = True\n        .Wrap = wdFindContinue\n        .Format = False\n        .MatchCase = False\n        .MatchWholeWord = False\n        .MatchWildcards = False\n        .MatchSoundsLike = False\n        .MatchAllWordForms = False\n    End With\n    Selection.Find.Execute\nEnd Sub


In a VB program I get the data from Oracle then use the macros as follows:
\n  Public gApp As Word.Application\n  Dim wDoc As Word.Document\n\n  Set gApp = New Word.Application\n  Set wDoc = gApp.Documents.Open(OriginalLetter, , True)\n\n  Call gApp.Run("FindReplace", "<DATE>", Format(Date, "Long Date"))\n\n  Call gApp.Run("Find", "<CUSTOMER_INFO>")\n  gApp.Selection.TypeText Address(pCust, pLoc)\n  \n  Call gApp.Run("FindReplace", "<ACCOUNT_REP>", AccountRep("1", pCust, pLoc))\n  Call gApp.Run("Find", "<LATE_INVOICES>")\n  \n  gApp.Selection.PageSetup.LeftMargin = InchesToPoints(1)\n  gApp.Selection.PageSetup.RightMargin = InchesToPoints(1)\n\n  gApp.Selection.ParagraphFormat.TabStops.Add InchesToPoints(0.2), wdAlignTabLeft\n  gApp.Selection.ParagraphFormat.TabStops.Add InchesToPoints(0.9), wdAlignTabLeft\n  gApp.Selection.ParagraphFormat.TabStops.Add InchesToPoints(1.7), wdAlignTabLeft\n  gApp.Selection.ParagraphFormat.TabStops.Add InchesToPoints(3.2), wdAlignTabLeft\n  gApp.Selection.ParagraphFormat.TabStops.Add InchesToPoints(4.6), wdAlignTabRight\n  gApp.Selection.ParagraphFormat.TabStops.Add InchesToPoints(5.6), wdAlignTabRight\n  gApp.Selection.ParagraphFormat.TabStops.Add InchesToPoints(6.5), wdAlignTabRight\n\n  ... loop to read data and use gApp.Selection.TypeText to add list of late invoices\n\n  wDoc.SaveAs NewLetter, 100 ' 100 = Word 97-2003 & 6.0/95 format\n  wDoc.Close
Darrell Spice, Jr.            Trendy yet complex\nPeople seek me out - though they're not sure why\n[link|http://spiceware.org/gallery/ArtisticOverpass|Artistic Overpass]                      [link|http://www.spiceware.org/|SpiceWare]
New Tried it & got a security error
On the statement "Set gApp = New Word.Application" I get the following:

===========================================================================

Access is denied.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

===========================================================================

Right clicking on Winword.exe and going to the security tab, I've given full rights to Anonymous, Guest, <system>\\Aspnet and Internet Guest Account. I don't have a 'IUSR_MACHINENAME' logon available, even when going to Add User -> Advanced -> Find Now.

I have no way of knowing exactly what 'user' the program is using in its attempt to fire up Word, so I can't create the user locally to make the program happy. Nor does the VB.Net code allow me to specify a user in the Word object creation statement.
lincoln

"Chicago to my mind was the only place to be. ... I above all liked the city because it was filled with people all a-bustle, and the clatter of hooves and carriages, and with delivery wagons and drays and peddlers and the boom and clank of freight trains. And when those black clouds came sailing in from the west, pouring thunderstorms upon us so that you couldn't hear the cries or curses of humankind, I liked that best of all. Chicago could stand up to the worst God had to offer. I understood why it was built--a place for trade, of course, with railroads and ships and so on, but mostly to give all of us a magnitude of defiance that is not provided by one house on the plains. And the plains is where those storms come from." -- E.L. Doctorow


Never apply a Star Trek solution to a Babylon 5 problem.


I am not merely a "consumer" or a "taxpayer". I am a Citizen of the United States.


[link|mailto:bconnors@ev1.net|contact me]
Expand Edited by lincoln June 29, 2006, 05:15:17 PM EDT
New Don't do it man! Don't do it!
This is an [link|http://support.microsoft.com/kb/q257757/|old article], but I think it still applies and gives a hint of a likely cause of your error message:

User Identity: Office Applications assume a user identity when they are run, even when they are started by Automation. They attempt to initialize toolbars, menus, options, printers, and some add-ins based on settings in the user registry hive for the user who launches the application. Many services run under accounts that have no user profiles (such as the SYSTEM or IWAM_[servername] accounts), and therefore Office may fail to initialize properly on startup, returning an error on CreateObject or CoCreateInstance. Even if the Office application can be started, without a user profile other functions may fail to work properly. If you plan to Automate Office from a service, you need to configure either your code or Office so that it will run with a loaded user profile.


I'd try to find a 3rd party library that can write into Word or RTF files, or if you can limit your support to Word 2003, look into WordML.

--
Chris Altmann
New So should I try the Crystal Reports option?
I've never used CR within a program. Do I create a screen that brings up a copy of the report, let the user fill it in, and then email/print it?

What's your recommendation?
lincoln

"Chicago to my mind was the only place to be. ... I above all liked the city because it was filled with people all a-bustle, and the clatter of hooves and carriages, and with delivery wagons and drays and peddlers and the boom and clank of freight trains. And when those black clouds came sailing in from the west, pouring thunderstorms upon us so that you couldn't hear the cries or curses of humankind, I liked that best of all. Chicago could stand up to the worst God had to offer. I understood why it was built--a place for trade, of course, with railroads and ships and so on, but mostly to give all of us a magnitude of defiance that is not provided by one house on the plains. And the plains is where those storms come from." -- E.L. Doctorow


Never apply a Star Trek solution to a Babylon 5 problem.


I am not merely a "consumer" or a "taxpayer". I am a Citizen of the United States.


[link|mailto:bconnors@ev1.net|contact me]
New Sure
You should be able to generate it server side. Here's an example that generates a PDF and returns it to the web user.
[link|http://msdn.microsoft.com/library/default.asp?url=/library/en-us/crystlmn/html/crtskexportingwebbasedreports.asp|http://msdn.microsof...bbasedreports.asp]

You would of course generate a Word doc and send it via email.

PS: Note that I haven't actually done this, but I might someday, so I looked into it.
--
Chris Altmann
New This may help you
If you code for windows automation and you need a process that launches other programs and controls them, this is a good start:
[link|http://www.firedaemon.com/|http://www.firedaemon.com/]

I use it for running my perl based automation stuff, which picks up control files and then executes windows programs.
     Requesting advice on how to do this - (lincoln) - (8)
         make word template, save as html doc - (boxley)
         Re: Requesting advice on how to do this - (SpiceWare) - (5)
             Tried it & got a security error - (lincoln) - (4)
                 Don't do it man! Don't do it! - (altmann) - (2)
                     So should I try the Crystal Reports option? - (lincoln) - (1)
                         Sure - (altmann)
                 This may help you - (broomberg)
         My solution - (lincoln)

We've got a whole bag of *tsht* with your name on it!
63 ms