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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbs script creating pivot table

Status
Not open for further replies.

daillest319

Programmer
Apr 9, 2012
29
0
0
US
i have most of my code created im just having trouble coverting this to work in my vbs script. can anyone help?



Code:
    ActiveSheet.PivotTables("Pivot Table").PivotSelect "Year[All;Total]", _
        xlDataAndLabel, True
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 12632256
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Selection.Font.Bold = True
        ActiveSheet.PivotTables("Pivot Table").PivotSelect "Hospital[All;Total]", _
        xlDataAndLabel, True
    Selection.Font.Bold = True
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 12632256
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    ActiveSheet.PivotTables("Pivot Table").PivotSelect "'Column Grand Total'", _
        xlDataAndLabel, True
    Selection.Font.Bold = True
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 12632256
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Range("E5").Select
 
I got it to .PivotSelect to select the rows i want but the code craps out and doesnt format at all....any help would be great





Code:
	With xlApp.Workbooks("Test.xls").ActiveSheet.PivotTables("PivotTable1")
		.PivotSelect "Year[All;Total]", xlDataAndLabel
                      'THIS PART DOESNT WORK IT SPITS BACK AND ERROR                                
                                .Font.Name = "Times New Roman"
                                .Font.Size = "10"
    END WITH
 
hi,

Maybe this...
Code:
    With xlApp.Workbooks("Test.xls").ActiveSheet.PivotTables("PivotTable1")
        .PivotSelect "Year[All;Total]", xlDataAndLabel
'THIS PART DOESNT WORK IT SPITS BACK AND ERROR[b]
        With Selection[/b]
            .Font.Name = "Times New Roman"
            .Font.Size = "10"[b]
        End With[/b]
    End With


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
or maybe it should be...
Code:
    With xlApp.Workbooks("Test.xls").ActiveSheet.PivotTables("PivotTable1")
        .PivotSelect "Year[All;Total]", xlDataAndLabel
'THIS PART DOESNT WORK IT SPITS BACK AND ERROR
        With [highlight]xlApp.[/highlight]Selection
            .Font.Name = "Times New Roman"
            .Font.Size = "10"
        End With
    End With


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
cant believe the error was...


With xlApp.Selection



thank you so much
 
how can add borders?

Code:
With xlApp.Workbooks("Test.xls").ActiveSheet.PivotTables("PivotTable1")
        .PivotSelect "Year[All;Total]", xlDataAndLabel
'THIS PART DOESNT WORK IT SPITS BACK AND ERROR
        With xlApp.Selection
            .Font.Name = "Times New Roman"
            .Font.Size = "10"
.xlEdgeBottom = 9 
				'.xlEdgeLeft = 7 
				'.xlEdgeRight = 10 
				'.xlEdgeTop = 8
        End With
    End With 


.xlEdgeBottom = 9 
				'.xlEdgeLeft = 7 
				'.xlEdgeRight = 10 
				'.xlEdgeTop = 8
 
I code VBA, so I insinctively ignore the application object: VERY necessary in VBS!!! ;-)

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
how can add borders?

Code:
With xlApp.Workbooks("Test.xls").ActiveSheet.PivotTables("PivotTable1")
        .PivotSelect "Year[All;Total]", xlDataAndLabel
'THIS PART DOESNT WORK IT SPITS BACK AND ERROR
        With xlApp.Selection
            .Font.Name = "Times New Roman"
            .Font.Size = "10"

'ThIS DIDNT WORK
            .xlEdgeBottom = 9 
	   .xlEdgeLeft = 7 
	   .xlEdgeRight = 10 
	   .xlEdgeTop = 8
        End With
    End With
 

example
Code:
'.xlEdgeBottom = 9 
    with .Borders(9)
'now do something with the bottom edge border properties

    end with


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top