Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening word and pdf files

Status
Not open for further replies.

chaosguy

Programmer
Nov 5, 2005
45
0
0
VC
hey i want a button to open a microsoft word document names "User Maunel".
I also need one to open a pdf file also called user manuel. How do I do this, all i can do is open a blank media document which I do not want :(. Can anyone help?

Chaosguy - To die would be an awefully big adventure.
 
The following will get you started with opening the Word document. This sets the path to the doc file with variables if you know the actual path then the use that.

This might not be the best way or the only way but it works and has not caused us problems as long as the human element is not included.


Dim DB As Database
Dim WordObj As Word.Application
Dim WordDoc As Word.Document
Dim fleNme As String
Dim Fldnme As String
Dim MyPath2 As String
Dim Mypath As String
Dim wordRange As Word.Range
Dim Regnme As Recordset
Dim Var, Var2
Set DB = CurrentDb
Set Regnme = DBEngine(0).Databases(0).OpenRecordset("tblregistrantName")
fleNme = Regnme!AuditName
Fldnme = Regnme!FolderName
Mypath = "C:\my documents\" + Fldnme
MyPath2 = Mypath + "\" + fleNme + "AD6A" + ".doc"
On Error Resume Next
Var2 = 1
Set WordObj = GetObject(, "Word.Application")
If Err <> 0 Then
Set WordObj = CreateObject("Word.Application")
Err.Clear
End If

Var = WordObj.Windows.Count
If Var <> 0 Then
Do Until Var2 = Var + 1
WordObj.Windows(Var2).Activate
If MyPath2 = WordObj.ActiveDocument.Name Then
GoTo line1:
End If
Var2 = Var2 + 1
Loop
End If
Set WordDoc = WordObj.Documents.Open(MyPath2)

line1:
Regnme.Close
Set Regnme = Nothing

WordObj.Visible = True
WordObj.Application.WindowState = wdWindowStateMaximize
Set WordObj = Nothing


 
Hmmmm, there was no mention of a database.
Hmmmm, there was no mention of ANY application that this button is supposed to be in.

So - hmmmm, a button WHERE? Plus, as this (at least apparently) is a question that simply asks how to opena Word file, and how to open a pdf file (not that being a pdf is really relevant)...this can be easily determined by using the macro recorder.

What exactly is the problem, and what have you tried so far?

Gerry
 
Um, wow that was a long and lot of stuff to do, but I figured it out tho. wel actually it was on another post. anyways i used this sort line and it workds fine. thank u

Private Sub help_Click()
Set Sh = CreateObject("WScript.Shell")
Sh.Run Chr(34) & "E:\Projects\CIE Project\Documentation\Help.doc" & Chr(34)
End Sub

Chaosguy - To die would be an awefully big adventure.
 
Have to say this was a confusing post. The question was how to open a word doc (named Manual.doc), and how to open a pdf file (also named manual). AND the answer is:

using WSShell to open Help.doc.

Hmmmmm...OK, glad it - something - worked. Why you are using WSShell Run to open a word doc? But hey, never mind....

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top