Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi user pasting problems

Status
Not open for further replies.

Zig999

Programmer
Nov 8, 2005
20
BR
I have a Client/Server web application that uses Word to modify a doc file and show it to the user. This modification is pasting a staple at all document pages.

If only one user is using the sistem, everything works fine, but if I have multiple users..well, 2 or more, I start getting errors on the "paste" code.

Any idea of what might bew the problem?
Thanks

Zig
 
dunno - telepathy mode is currently not engaged.
You know your code and how it is meant to work.
We don't.
You need to give far more info and some examples of the code that is falling over and where it is falling over....

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Gosh Geoff, MY mind reading is working fine. The error is in line 16...or is 2? Darn.

Gerry
 
[LOL]

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
What I´m looking for is someone that already had problems with scripts running on a server like multithread problems or maybe compatibility problems with Word versions. something that works for ONE user and has problems with TWO or MORE.
If the code helps...
Here is the hole code and it really works for one user at a time.
It works with two Word documents, one is the model witch has the staple to be pasted in the edited document. The model only exist for that pourpose.. so we have the staple model, and the other document is uploaded by the user, that will have its content modified.

This is in lotusscript...
The error always ocours it tries to paste the staple; and only, only ocours if two users execute it at the same time.

Code:
Set wrd = CreateObject("Word.Application")
	
	Set wrdModel = wrd.documents.open(tempdir + "\" + modelFileName)	
	Set wrdToEdit = wrd.documents.open(tempdir+"\"+DocumentFilename)
	
	wrdModel.Activate
	wrdModel.Sections(1).Range.ShapeRange.Select
	wrdModel.Application.Selection.Copy
	wrdToEdit.Activate
	With wrdToEdit					
		Forall section In .Sections
			Forall header In section.Headers
				Forall hShape In header.Shapes
					Dim shapeFix As Integer
					shapeFix = Fix(hShape.Height)
					If shapeFix <= 54 And shapeFix >= 52 Then
'						hShape.delete
						hShape.Height = 0
					End If
				End Forall
			End Forall
		End Forall
		
		'Primeira página		
		.Application.Selection.HomeKey 6		
		.Application.Selection.GoTo 0,1,1,""
		With .Application.Selection.PageSetup
			.OddAndEvenPagesHeaderFooter = False
			.DifferentFirstPageHeaderFooter = False
		End With
		.Sections(1).Headers().Item(1).LinkToPrevious = False
		.Sections(1).Headers().Item(2).LinkToPrevious = False
		.Sections(1).Headers().Item(3).LinkToPrevious = False		
		.Sections(1).Headers(1).Range.Paste
		With .Application.Selection.PageSetup
			.OddAndEvenPagesHeaderFooter = False
			.DifferentFirstPageHeaderFooter = True
		End With
		.Sections(1).Headers(2).Range.Paste
		
		'Demais páginas
		Dim i As Integer
		For i = 2 To .Sections.Count
			.Application.Selection.GoTo 0,1,i,""
			With .Application.Selection.PageSetup
				.OddAndEvenPagesHeaderFooter = False
				.DifferentFirstPageHeaderFooter = False
			End With
			.Sections(i).Headers().Item(1).LinkToPrevious = False
			.Sections(i).Headers().Item(2).LinkToPrevious = False
			.Sections(i).Headers().Item(3).LinkToPrevious = False
		Next	
		
		For i = 2 To .Sections.Count
			.Application.Selection.GoTo wdGoToSection,wdGoToAbsolute,i,""
			If .ActiveWindow.View.SplitSpecial <> wdPaneNone Then
				.ActiveWindow.Panes(2).Close
			End If
			If .ActiveWindow.ActivePane.View.Type = wdNormalView Or .ActiveWindow.ActivePane.View.Type = wdOutlineView Then
				.ActiveWindow.ActivePane.View.Type = wdPrintView
			End If
			.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader			
			'Msgbox "ACTIVE DOCUMENT"
			'Msgbox .FullName
			'Msgbox "          - Orientation "+Cstr(.Sections(i).PageSetup.Orientation)
			If .Sections(i).PageSetup.Orientation = 0 Then
				'PORTRAIT
				'Msgbox "      Seção: " + Cstr(i) + " - ENTROU Orientation 0"
				wrdModel.Activate
				wrdModel.Sections(1).Range.ShapeRange.Select
				wrdModel.Application.Selection.Copy
				wrdToEdit.Activate
			Else
				'LANDSCAPE
				'Msgbox "      Seção: " + Cstr(i) + " - ENTROU Orientation 1"
				wrdModel.Activate
				wrdModel.Sections(2).Range.ShapeRange.Select
				wrdModel.Application.Selection.Copy
				wrdToEdit.Activate
			End If
			.Sections(i).Headers(1).Range.Select
			.Application.Selection.Paste			
		Next			
		.Save
		.Close
	End With
 
Another thing...
I´m testing the script with 2 users. One always get the document returned.. and the other don´t. In the server console the error raised is this.

"This method or property is not available because the Clipboard is empty or not valid"

Another thing I found today is that this only occours with documents made on Word 97.

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top