wannabepro
Registered User.
- Local time
- Today, 11:31
- Joined
- Jan 25, 2005
- Messages
- 102
I want to view an attched word document. But I keep getting this msg that Type mismatch. I got this script from one of the posts here. I made few changes in it so it can attach word file. Now its attaching word file but only the viewing part is giving me trouble.
To attach file!
Private Sub SelectFile_Click()
Dim OFN As OPENFILENAME
On Error GoTo Err_SelectFile_Click
' Set options for dialog box.
With OFN
.lpstrTitle = "Select Documents"
If Not IsNull([QuoteWorkout]) Then .lpstrFile = [QuoteWorkout]
.flags = &H1804 ' OFN_FileMustExist + OFN_PathMustExist + OFN_HideReadOnly
.lpstrFilter = MakeFilterString("Word files (*.doc)", "*.doc", _
"All files (*.*)", "*.*")
End With
If OpenDialog(OFN) Then
[QuoteWorkout] = OFN.lpstrFile
' [imgPicture].Picture = [PicFile]
' SysCmd acSysCmdSetStatus, "Afbeelding: '" & [PicFile] & "'."
End If
Exit Sub
Err_SelectFile_Click:
MsgBox Err.Description, vbExclamation
End Sub
To View File
Private Sub ViewCalc_Click()
On Error GoTo Err_ViewCalc
Dim XL As Object
Set XL = CreateObject("Word.Application")
If IsNull(Me.QuoteWorkout) Then
MsgBox "You haven't Attached a Calculation File", , "Error"
Else
With XL.Application
.Visible = True
.documents.Open Me.QuoteWorkout
End With
Set XL = Nothing
End If
Exit_ViewCalc_Click:
Exit Sub
Err_ViewCalc:
MsgBox Err.Description
Resume Exit_ViewCalc_Click
End Sub
I hope I am making sense, I just need lil help in correcting the viewing script.
To attach file!
Private Sub SelectFile_Click()
Dim OFN As OPENFILENAME
On Error GoTo Err_SelectFile_Click
' Set options for dialog box.
With OFN
.lpstrTitle = "Select Documents"
If Not IsNull([QuoteWorkout]) Then .lpstrFile = [QuoteWorkout]
.flags = &H1804 ' OFN_FileMustExist + OFN_PathMustExist + OFN_HideReadOnly
.lpstrFilter = MakeFilterString("Word files (*.doc)", "*.doc", _
"All files (*.*)", "*.*")
End With
If OpenDialog(OFN) Then
[QuoteWorkout] = OFN.lpstrFile
' [imgPicture].Picture = [PicFile]
' SysCmd acSysCmdSetStatus, "Afbeelding: '" & [PicFile] & "'."
End If
Exit Sub
Err_SelectFile_Click:
MsgBox Err.Description, vbExclamation
End Sub
To View File
Private Sub ViewCalc_Click()
On Error GoTo Err_ViewCalc
Dim XL As Object
Set XL = CreateObject("Word.Application")
If IsNull(Me.QuoteWorkout) Then
MsgBox "You haven't Attached a Calculation File", , "Error"
Else
With XL.Application
.Visible = True
.documents.Open Me.QuoteWorkout
End With
Set XL = Nothing
End If
Exit_ViewCalc_Click:
Exit Sub
Err_ViewCalc:
MsgBox Err.Description
Resume Exit_ViewCalc_Click
End Sub
I hope I am making sense, I just need lil help in correcting the viewing script.