View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default sheets(N*).printout problem

Where you have these lines:

''Workbooks(Caminho).Save
'Printing
Worksheets(4).PrintOut


For testingk, modify to this:

''Workbooks(Caminho).Save
MsgBox ActiveWorkbook.Name
'Printing
Worksheets(4).PrintOut

If the workbook name displayed in the message box is not the one with the
sheet to copy then you will need to activate the correct workbook.







"Paulo" wrote:

thank you for the ilustrative explanation. but none of the them happen in my
case.

I have 100 workbooks with the same structure.
6 sheest, none have macro, so the probably dont have hidden sheets. other
than

The error happends in the printout part, all the rest of the code goes
smoothly.
if i were mistaken on the Sheets(n*) , i woul have
Sheets(4).Range("C39").Formula = "=round((0.25*$c$24),2)"
on the wrong sheet, and that didnt happen.

i have changed this lines to doublecheck - but no joy, erro #9 ;)
Worksheets("CAL.ECON.").PrintOut
MsgBox "Vire A página"
Worksheets("DETALHADA").PrintOut
Worksheets("CAL.ECON.").Protect "CECAPF"
Worksheets(1).Range("c2").Select
'Workbooks(Caminho).Save
Workbooks(Caminho).Close SaveChanges:=True



"Paulo" wrote:

why do I get erro #9 @ printing?
i have a other sub that runs the same line in the local woorkbook and ptints
just fine.
I thank in advance

Sub Imprimidor()

' On Error GoTo Fim

Dim x As Long
Dim Y As Long
Dim Formul As String
Dim Seq As Long
Dim Adit As String
Dim Clie As String
Dim Caminho As String
Y = Range("E1")
For x = Y To 27
Seq = Cells(x, "a").Value
Adit = Cells(x, "b").Value
Clie = Cells(x, "c").Value
Range("D" & x).Value = "ok"

Caminho = "\\Servidor\dados\ADITIVOS\" & Clie & "\(" _
& Seq & ") " & Clie & " aditivo " & Adit & " -TC- 1008 -
N.xls"
Debug.Print Caminho
Workbooks.Open Caminho
ActiveWorkbook.UnprotectSharing
If ActiveWorkbook.MultiUserEditing Then ActiveWorkbook.ExclusiveAccess
'If ActiveWorkbook.ProtectStructure = True Then
Sheets(4).Unprotect "CECAPF"
Sheets(4).Range("C39").Formula = "=round((0.25*$c$24),2)"
Workbooks.Open(Filename:= _
"C:\Arquivos de programas\Microsoft
Office\OFFICE11\Bibliote\Analise\ATPVBAEN.XLA" _
).RunAutoMacros Which:=xlAutoOpen
Calculate
'Sheet1.Range("c2").Select
''Workbooks(Caminho).Save
'Printing
Worksheets(4).PrintOut
MsgBox "Vire A página"
Worksheets(2).PrintOut
Worksheets(4).Protect "CECAPF"
Worksheets(1).Range("c2").Select
'Workbooks(Caminho).Save
Workbooks(Caminho).Close SaveChanges:=True
Next
end sub