Opening Word from Within Access

G

Guest

I wish to open a blank word file from a hyperlink within access. I have
succeeded in opeing word but is there a way I can code it so that word opens
with a new document ready to go.

My code so far is: -


Private Sub RunWord_Click()
On Error GoTo Err_RunWord_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Exit_RunWord_Click:
Exit Sub

Err_RunWord_Click:
MsgBox Err.Description
Resume Exit_RunWord_Click

End Sub


Any help would be appreciated.

Regards

Juparo
 
G

Guest

Try something like

'****** Code End ********
Function CreateDoc()

Dim wrdApp As Word.Application
Dim docCreate As Word.Document
Dim rgeDoc As Word.Range
Dim strTempFile As String

strTempFile = "C:\Documents\MyDoc.doc"

Set wrdApp = New Word.Application
Set docCreate = wrdApp.Documents.Add(DocumentType:=wdNewBlankDocument)
Set rgeDoc = docCreate.Range

wrdApp.Visible = True

'With rgeDoc
' .InsertParagraphAfter
' .InsertParagraphAfter
' .InsertAfter "Typing here for the body of the document."
' '{more text}
'End With
'
'docCreate.SaveAs strTempFile
'docCreate.Close wdSaveChanges
'wrdApp.Quit
'
'Set wrdApp = Nothing

End Function
 
G

Guest

Thanks David - will give it ago.

Daniel said:
Try something like

'****** Code End ********
Function CreateDoc()

Dim wrdApp As Word.Application
Dim docCreate As Word.Document
Dim rgeDoc As Word.Range
Dim strTempFile As String

strTempFile = "C:\Documents\MyDoc.doc"

Set wrdApp = New Word.Application
Set docCreate = wrdApp.Documents.Add(DocumentType:=wdNewBlankDocument)
Set rgeDoc = docCreate.Range

wrdApp.Visible = True

'With rgeDoc
' .InsertParagraphAfter
' .InsertParagraphAfter
' .InsertAfter "Typing here for the body of the document."
' '{more text}
'End With
'
'docCreate.SaveAs strTempFile
'docCreate.Close wdSaveChanges
'wrdApp.Quit
'
'Set wrdApp = Nothing

End Function
 

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

Top