Button to open new document

  • Thread starter Thread starter meghanwh
  • Start date Start date
M

meghanwh

I'd like to put a button on a form that creates a new word document
(actually I'd like to also have a button to create a new email). I've
searched for code for it, but all I can find is to open an already
existing document. Please help. Thanks!
 
I'd like to put a button on a form that creates a new word document
(actually I'd like to also have a button to create a new email). I've
searched for code for it, but all I can find is to open an already
existing document. Please help. Thanks!

Email code (make sure that you've set a reference to Outlook):

http://www.datastrat.com/Code/OutlookEmail.txt

Word code (late binding reference not needed):

Private Sub cmdWord_Click()
Dim objWord As Object

Set objWord = CreateObject("Word.Application")
With objWord
.Documents.Open ("C:\Path to your WordDoc.doc")
.Visible = True
End With
Set objWord = Nothing

End Sub
 
Email code (make sure that you've set a reference to Outlook):

http://www.datastrat.com/Code/OutlookEmail.txt

Word code (late binding reference not needed):

Private Sub cmdWord_Click()
Dim objWord As Object

Set objWord = CreateObject("Word.Application")
With objWord
    .Documents.Open ("C:\Path to your WordDoc.doc")
    .Visible = True
End With
  Set objWord = Nothing

End Sub

Thanks. But what I'm having trouble with is that there isn't a file
already created, thus no path name. How can I get it to just open a
new, blank document?
 
Instead of:

Documents.Open ("C:\Path to your WordDoc.doc")

Use:

objWord.Documents.Add ("Normal.dot")
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Email code (make sure that you've set a reference to Outlook):

http://www.datastrat.com/Code/OutlookEmail.txt

Word code (late binding reference not needed):

Private Sub cmdWord_Click()
Dim objWord As Object

Set objWord = CreateObject("Word.Application")
With objWord
.Documents.Open ("C:\Path to your WordDoc.doc")
.Visible = True
End With
Set objWord = Nothing

End Sub

Thanks. But what I'm having trouble with is that there isn't a file
already created, thus no path name. How can I get it to just open a
new, blank document?
 
Back
Top