1

Topic: VBS and Word

In advance I apologize at moderators for creation of a repeated subject, the subject is created in other section. But probably to me can help here?

2

Re: VBS and Word

The question is solved. Login and the password have not been registered in adjustments DCOM in Windows for Word service

3

Re: VBS and Word

Time addressed, prompt as correctly to organize search and text changeover. Under the documentation looked and  here so, but the document is not formed, hangs and

Set wApp = CreateObject ("Word. Application")
wApp. Application. Visible = False
wApp. DisplayAlerts = 0
Set wDoc = wApp. Documents. Open (Server. MapPath ("the Way to a file"))
Set wSel = wApp. Selection
' Search and changeover
With wSel. Find
.ClearFormatting
.MatchWholeWord = True
.Forward. = True
.MatchCase = False
.ReplaceWith = "the Text which we replace that that found"
.Execute ("for the Text which we search")
End With

If that is is written on VBS

4

Re: VBS and Word

Well short of late binding and absence of determination of variables - on VBA there will be one in one same code. Which easily turns out a vulgar macrorecorder.

5

Re: VBS and Word

dartveider13 wrote:

hangs and

and what you would want after that?

dartveider13 wrote:

wApp. Application. Visible = False

6

Re: VBS and Word

I think that  that word produces in the end the message how many was changeovers though I like ungeared show of messages

7

Re: VBS and Word

Variables are defined. Simply I here did not describe them. If  that the server would produce them . And what for to me visibility of a Word if it on a server is launched and is then downloaded from it

8

Re: VBS and Word

By the way even if to include visibility, on the server I do not see it. Process appears, and windows

9

Re: VBS and Word

To use COM-interaction with office on the server - the bad idea, even the microsoftware does not recommend

10

Re: VBS and Word

Well I while do not have other variants. An ex-fur-tree like anything. Works on the sly.

11

Re: VBS and Word

dartveider13 wrote:

.Forward>>>. <<<= True

and it that the such?

12

Re: VBS and Word

Shocker. Pro, I apologize, it I here was sealed up. The computer the worker is not connected to an Internet. In the code it is written.Forward = True

13

Re: VBS and Word

dartveider13;
Are assured, what search generally reaches? After all the variant is quite possible that the document from the server simply does not want to open or opens in the protected mode.
Did not try to fulfill the code from Excel, for example? That in a mode of step by step debugging at all to look.
If the file opens also business really in the message on changeover - that it is possible to try to disconnect show of messages before code performance (optimally, before discovery of file Word):

wApp. DisplayAlerts = False

Only in the end of the code in True it is better to return.

14

Re: VBS and Word

The_Prist, yes I checked it is removed search. It to me saved a server file. And False too tried to put - does not help

15

Re: VBS and Word

Though, business, like  all and again  can already and not in it. I Will think. Tell, and as a whole the code of search and changeover the correct?

16

Re: VBS and Word

I think business in Documents. Open. Before at me it has been registered with a heap of commas and pair of properties. Then I thought to remove them and to leave only a way to a file. On it and  all... When on a server Word process, a broad gull this line  has been killed. Business means further it not went. I try to recall as it has been written)))

17

Re: VBS and Word

Not clear hogwash what that with a file was. Opened it on a server, he wrote what that an error,  it and all became normal. All right I will try further.  I will try to return search

18

Re: VBS and Word

in search not so. He at first swears on what  property, and then in a precipitate falls out if on the second circle to try to load

19

Re: VBS and Word

Misters, and tell to me if Word and Excel it is not recommended to use in the Web server that then it is better to use for the reporting in sheaf IIS+ASP (not NET) +HTML+JavaScript+VbScript?

20

Re: VBS and Word

by means of Google and what that there mothers, won search and changeover. To a clod is interesting it turned out all here so (if I will be sealed up I ask not to kick strongly - the working computer is not connected to an Internet, I write hands):

Dim wApp, wDoc, wSel, FSO, Stream
Set wApp = CreateObject ("Word. Application")
wApp. Application. Visible = False
wApp. DisplayAlerts = 0
Set wDoc = wApp. Documents. Open (Server. MapPath ("the relative way to a file"), False, True)
Set wSel = wApp. Selection
' the Search algorithm and changeovers
wSel. Find. ClearFormatting
wSel. Find. Replacement. ClearFormatting
With wSel. Find
.Replacement. Text = "the text on which is replaced"
.MatchWholeWord = True
.Text = "for the Text which we search"
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWildcards = False
.MatchSoundsLike = False
.Execute, wdReplaceAll
End With
' Saving and downloading of the document from the server
Set FSO = CreateObject ("Scripting. FileSystemObject")
If FSO.FileExists ("a way to a file") Then FSO.DeleteFile (a way to a file)
wDoc. SaveAs "a way to a file", 0
Set FSO = Nothing
wDoc. Close False
wApp. Quit
Set Stream = CreateObject ("ADODB.Stream")
Stream. Type = 1
Stream. Open
Stream. LoadFromFile "a way to a file"
Response. ContentType = "Application/VND.MS-Word"
Response. AddHeader "Content-Disposition", "attachment; filename =" and "file name without a way for example 111.doc"
Response. BinaryWrite Stream. Read
Response. Flush
Response. End
Stream. Close
Set Stream = Nothing

, well also do not forget to define  a constant))) All thanks for responses