Problems when converting VBA code into Word 2007

D

d_freshman

I have some code that I run from a Access 2007 Form that runs in Access
2003/Word 2003 but is not working in Word 2007. I think its a security issue
but not certain.

The code:

Public Sub MacroHeatAblation(strPatientName As String, _
strProcedureDate As String, _
strArrivalTime As String, _
strProcedureTime As String)
Dim intReturn As Integer
Dim oWordApp As Word.Application
Dim oWordDoc As Word.Document
Dim strDocName As String
On Error Resume Next
intReturn = MsgBox("The following items have been identified to insert
into the letter." & vbCrLf & _
"If <blank> then no value has been saved for that
item." & vbCrLf & vbCrLf & _
"Patient Name : " & strPatientName & vbCrLf & _
"Procedure Date : " & strProcedureDate & vbCrLf & _
"Arrival Time : " & strArrivalTime & vbCrLf & _
"Procedure Time : " & strProcedureTime & vbCrLf &
vbCrLf & _
"Do you want to continue to edit the letter?",
vbYesNo, "Word Template Items")
If intReturn = 6 Then
strDocName = "C:\Program Files\OODocs\Heat Ablation instructions1.doc"
Set oWordApp = New Word.Application
Set oWordDoc = oWordApp.Documents.Add(strDocName, , , Visible:=True)

With oWordApp

.Visible = True

....etc. more code

End Sub

Description of the problem:

At first, Word 2007 would open but no document would be showing. Word 2007
deleted the folder where the document lives. So I tried the following:
1. Opened Trust Center in Word and added the folder location as a Trusted
Location. (result was that Word opened and the folder location got deleted)
2. Saved the document in the new word format (.docx) and put it in the
c:\Program files\Microsoft Office\Templates Folder (changing the strDoc in
the above code to match) (result was Word opened, no document showed,
although the document was not deleted from the folder)

Any help would be apprieciated. Thanks
 
D

Doug Robbins - Word MVP

Try saving Heat Ablation instructions1 as a template (.dot) in the Word
Templates folder.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

d_freshman

Thanks Doug,

Not sure why Trusted Template location wouldn't take my original folder
name, but your suggestion worked.

David
 

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