Sabtu, 29 Oktober 2011

[MS_AccessPros] Re: Opening MS Word from Access

 

Hi David,

The CurrentProject.Path gives you the folder in which your database resides. You will have to enter the path in your code or you could using code:

.Documents.Open GetMyDocumentsDir & strMergeLetterName

Function GetMyDocumentsDir() As String
If gbolErrorTrapOff = False Then On Error GoTo ErrHandle

Dim strValue As String

strValue = Environ("USERPROFILE") & "\My Documents\"

GetMyDocumentsDir = strValue

ExitHere:
Exit Function

ErrHandle:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description _
& vbCrLf & "In procedure GetMyDocumentsDir"
Resume ExitHere

End Function

Kind Regards,
Patrick Wood, Access MVP
Access Easy Tips Blog
http://accesstips.wordpress.com
Microsoft Access and SQL Azure Information Center for Developers
http://gainingaccess.net/SQLAzure/AccessAndSQLAzureInfo.aspx

--- In MS_Access_Professionals@yahoogroups.com, "djsdaddy531" <drtolson@...> wrote:
>
> Great Day, I have a form that produces a mail merge in MS Word, it works fine in Windows XP, but I am running Windows 7 now. I get this error when I execute the code:
>
> This file could no be found.
> ("C\...\Greetings")
>
>
> When I click "Debug" from the error message, this is the code that is highlighted:
>
> .Documents.Open CurrentProject.Path & strMergeLetterName
>
> The file is in My Documents, which is where I thought CurrentProject.Path would look.
>
> If anyone can straighten me up on this, I would be greatly appreciated.
>
> Thanks in advance,
>
> David
>

__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar