Opening Word from Within Access

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
Back
Top