Home > Software design >  Lotus Notes VBA make MS Word visible
Lotus Notes VBA make MS Word visible

Time:06-21

All,

I am trying to use MS Word to print the current web page. I have a print button that call an agent and run on the server. The problem is that it make MS Word visible on the server console and not on the user machine. If I run my agent locally, it will make MS Word visible on the user (or my machine).

I know this is all working like it should but I am wondering if there is a way to make MS Word visible when called from a button on the web calling an agent.

this is some of the code I am talking about:

Dim objWord As Variant
Dim docWord As Variant
    
Set objWord = CreateObject("Word.Application")  
    
objWord.Visible = true
    
Dim object As NotesEmbeddedObject
Dim rtitem As Variant   
    
    
Set docWord = objWord.Documents.Open("L:\Lotus\Domino\data\domino\html\Attachments\cal\templates\gage-grid111.docx")

CodePudding user response:

Basically no. All LotusScript on the web runs on the Domino server and can't do anything with client software, and there's nothing you can do about that as far as I know.

Some alternatives might be possible depending on the requirements of your application.

Firstly, does the thing you're printing have to be a Word document? If the same content can be generated with HTML and CSS, then you could open that as a normal web page and print it using client-side javascript.

If it really must be a Word document, then one of the following options might suit you:

  1. Store the Word document in a Notes document accessible to the web user, or in some other server-side location accessible by a URL, then show the web user a link to the Word document so they can download and print it; or...
  2. I've never tried this, but it might be possible to control Word on the client machine using ActiveXObject in javascript, or there may be some other Windows-only javascript feature to do this. If this is possible, browser support is likely to be limited, and subject to security restrictions.

CodePudding user response:

What exactly do you mean by "use Word to print the current page"? If it's the exact contents of the screen, why use Word when a browser can print the page? How is your web page created, using a Notes form or XPages?

Probably the best you can do is use CSS directives for when the document is printed. Either make a 2nd form that displays the data exactly as you want them printed, or put a hidden div in the same form (e.g. at the bottom) that contains the info to be printed. Use CSS in such a way that the original info isn't printed, only the normally hidden div.

You could print to a PDF file, I don't know if/how printing to Word works.

  • Related