Because your destroying the document object before adding the table to it. - Set doc = Nothing