The line
Dim a As Excel.Application
only declares a as being of that type, it doesn't create an Excel
object
(so a is Nothing, which is the reason for the error)

If you're using VBA within Excel the Application object already exists,
so you can just say

For Each wb In Application.Workbooks
' or even just For Each wb In Workbooks
wb.Save
Next wb

Hope this helps
Andrew

Suraj wrote:
> Hi,
>
> I am getting the error "Object Variable or With Block Variable not set"
> when I try to execute following VBA code.
>
> Dim a As Excel.Application
> Dim wb As Workbook
>
> For Each wb In a.Workbooks
> wb.Save
> Next wb
>
> Please let me know what is the problem
>
> Thanks,
> suraj