Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Kevin Jenkins   on Oct 08 In MS Office Category.

  
Question Answered By: Betty Fischer   on Oct 08

Before you can use an object  variable like Wbook, you have to use the SET
command to point it to a real object. For example:

Set Wbook = ActiveWorkbook

However, I'm not sure you need an object variable  in this case. Excel VBA has
a predefined object called ActiveWorkbook which always refers to the open
workbook which is currently active (to be sure it's the active workbook, click
in any cell in the workbook just before running your macro). Using
ActiveWorkbook the code  might look like this:

Sub testing()
Dim i As Integer
For i% = 1 To ActiveWorkbook.Sheets.Count
If LCase(Left(Sheets(i%).Name, 4)) = "exec" Then
Sheets(i).PrintOut Copies:=1
End If
Next i%
End Sub

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Print Or get search suggestion and latest updates.


Tagged: