Hi Guys,
Thanks for your help guy's!
I don't think my code as help to explain myself - apologies!
I'll try and explain a bit better:
I have some code that currently prints from a pivot table (see below)
Now instead of printing hard copies I'd like to print '*.mdi' files.
However, when printing to the Microsoft Office Document Image it asks for a 'save as' name. This is the bit I'd like to automate. I don't want the 'save as' window to pop up, I'd like the code to automatically name the 'mdi' file as the first 4 character of the excel workbook + the text in cell L1 + the text in cell M1.
Cheers,
Andy
Code:
Sub PrintAllEnquires()
Application.ScreenUpdating = False
'Removal Any Subtotals From BoQ
Sheets("BoQ").Select
[a2].Select
Selection.RemoveSubtotal
Sheets("BoQ Prints").Select
'Update Any Rogue Data In The Fields
With Sheets("BoQ Prints").PivotTables("BillsOfQuantities").PivotCache
.MissingItemsLimit = xlMissingItemsNone
.Refresh
End With
ActiveSheet.PivotTables("BillsOfQuantities").PivotFields("Volume").AutoSort _
xlAscending, "Volume"
ActiveSheet.PivotTables("BillsOfQuantities").PivotFields("Page").AutoSort _
xlAscending, "Page"
ActiveSheet.PivotTables("BillsOfQuantities").PivotFields("Headers").AutoSort _
xlAscending, "Headers"
ActiveSheet.PivotTables("BillsOfQuantities").PivotFields("Sub Ref").AutoSort _
xlManual, "Sub Ref"
Dim R As Long
'Loop till R = 65
For R = 6 To 65
'Cells(RowNumber,ColNumber)
If Cells(R, 12).Value > 0 And Cells(R, 14).Value > 0 Then
Cells(1, 12).Value = Cells(R, 12).Text
Application.ScreenUpdating = True
Application.ScreenUpdating = False
'Show All in Sub Ref Column
For Each pit In ActiveSheet.PivotTables("BillsOfQuantities").PivotFields("Sub Ref").PivotItems
pit.Visible = True
Next
'Show the Sub Ref in Cell P1 now named "SelectEnquiry"
For Each pit In ActiveSheet.PivotTables("BillsOfQuantities").PivotFields("Sub Ref").PivotItems
With pit
If .Value = [SelectEnquiry].Value Then
.Visible = True
Else
.Visible = False
End If
End With
Next
'Show All in theMarkup Column
For Each pit In ActiveSheet.PivotTables("BillsOfQuantities").PivotFields("Markup").PivotItems
With pit
If .Value = ("(blank)") Or .Value = ("0") Then
.Visible = True
Else
.Visible = True
End If
End With
Next
Application.ScreenUpdating = False
'Refresh the data
ActiveSheet.PivotTables("BillsOfQuantities").PivotCache.Refresh
Application.ScreenUpdating = False
'Show All in Sub Ref Column again
For Each pit In ActiveSheet.PivotTables("BillsOfQuantities").PivotFields("Sub Ref").PivotItems
pit.Visible = True
Next
Application.ScreenUpdating = False
'Show the Pages only in the Markup column
For Each pit In ActiveSheet.PivotTables("BillsOfQuantities").PivotFields("Markup").PivotItems
With pit
If .Value = ("0") Then
.Visible = False
Else
.Visible = True
End If
End With
Next
Range("B5").Select
Selection.ShowDetail = False
Sheets("Enq").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=Sheets("BoQ Prints").Cells(R, 14).Value
Sheets("BoQ Prints").Select
Range("B5").Select
Selection.ShowDetail = True
'Run Format Macro
Application.Run "BoQFormat"
With ActiveSheet
.PageSetup.RightFooter = ([L1]) + (". ") + ([M1]) + (" ENQUIRY")
End With
Application.ScreenUpdating = False
'Print the enquiry
ActiveWindow.SelectedSheets.PrintOut Copies:=Cells(R, 14).Value, Collate:=True
End If
Next R
With ActiveSheet
.Outline.ShowLevels ColumnLevels:=1
End With
[a6].Select
Application.ScreenUpdating = True
End Sub