Create a Word Doc from Access

Sade

Board Regular
Joined
Nov 29, 2004
Messages
145
Ok, I'm thinking this shouldn't be too much of an issue, but in my bone-headedness, I can't find the right commands. We are tracking complaints for our hospital, and I need each record to have an individual hyperlinked cell that points to the complaint description in a Word document (The description can be multiple pages long).

I can create the hyperlink by using code I found on this site.

Code:
Private Sub cmdFollowLink_Click()
Dim oWordApp As Object
Dim strAddress As String

strAddress = Forms!Form2!txtAddress

Set oWordApp = CreateObject("Word.Application")
oWordApp.Document.Open "C:\" & strAddress & ".doc"
oWordApp.Visible = True

End Sub

This opens a pre-existing Word document, but I need it to actually create one.

I'm thinking I just need to change the word "Open" to "New" or something like that, but I'm having trouble finding the right word.

Thanx

Sade
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Sade

To create a new Word document use Add.
Code:
oWordApp.Documents.Add

To name the new document I think you would have to save it.
Code:
oWordApp.Documents(1).SaveAs "C:\" & strAddress & ".doc"
By the way the code you posted is incorrect, it should be Documents not Document.
 
Upvote 0

Forum statistics

Threads
1,219,162
Messages
6,146,660
Members
450,706
Latest member
LGVBPP

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top