Create new blank document from Access

  • Thread starter Thread starter bdtmike
  • Start date Start date
B

bdtmike

I need to create a new blank document (e.g. Word, Excel, etc) from
within VBA.
This is the equivalent to right clicking on the desktop and clicking
"New..."

Is there a shell API function that will let me do this?
 
You can do that through ActiveX automation:

Dim xls As Excel.Application
Dim wd As Word.Application
Dim wk as Excel.Workbook
Dim doc As Word.Document

'Start Excel and open a new Workbook
Set xls=New Excel.Application
xls.Visible=True
Set wk=xls.Workbooks.Add("[Path to an Excel workbook template"])

''Start Word and add a new document
Set wd=New Word.Application
wd.Visible=True
Set doc=wd.Documents.Add("[Path to an Word document template"])

'Do something with the new workbook and the new document

wk.Close True
doc.Close True

xls.Quit
wd.Quit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top