TonyCro
Mechanical
- Jan 12, 2005
- 23
We have a simple spreadsheet that we log memos and other similar documents in and with some code to open these documents in word - and we're looking to see if we can have something similar for opening drawings saved in a PDF format. Unfortunately the code was written by a chap who has moved on and I have absolute zero experience in this field
The code we have for opening the word docs is;
------------------------------------------------------------
Code BlockOption Explicit
Dim Wordfile, Mypath, Mydir, Myfile, MyfilePath, Myappid, Author, Yr, Check, Response, Wordapp
Sub view_document()
On Error GoTo Errorhandler 'trap errors for processing
Wordfile = "C:\Program Files\Microsoft Office\Office\WINWORD.EXE "
'Set drive
Mypath = (Left(ActiveWorkbook.FullName, 2))
'Set directory for document dependent on which sheet user is on.
If ActiveSheet.Name = "Engineering Reports" Then
Mydir = "\Engineering\Engineering Reports\Engineering Reports +600\"
ElseIf ActiveSheet.Name = "Memo's" Then
Mydir = "\Engineering\Engineering Reports\Memo's\"
ElseIf ActiveSheet.Name = "DI's" Then
Mydir = "\Engineering\Engineering Reports\DI\"
End If
'set document user wishes to open
Myfile = ActiveSheet.Cells(ActiveCell.Row, "A")
MyfilePath = Mypath & Mydir & Myfile & ".doc"
Set Wordapp = CreateObject("Word.Application")
' Set Word to be visible and call up document
With Wordapp
.Visible = True
.documents.Open MyfilePath
End With
----------------------------------------------------------
and I tried the following changes;
Code BlockOption Explicit
Dim PDFfile, Mypath, Mydir, Myfile, MyfilePath, Myappid, Author, Yr, Check, Response, PDFapp
Sub view_document()
On Error GoTo Errorhandler 'trap errors for processing
PDFfile = "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe"
'Set drive
Mypath = (Left(ActiveWorkbook.FullName, 2))
'Set directory for document dependent on which sheet user is on.
If ActiveSheet.Name = "drawings" Then
Mydir = "\drawings\drawing list\"
End If
'set document user wishes to open
Myfile = ActiveSheet.Cells(ActiveCell.Row, "A")
MyfilePath = Mypath & Mydir & Myfile & ".pdf"
Set PDFapp = ("PDF.application")
' Set Word to be visible and call up document
With PDFapp
.Visible = True
.documents.Open MyfilePath
End With
End
Since it's clear I'm in way over my head, I'm hoping that you wonderful peeps might be willing to point me in the right direction.
Many thanks
Tony.
The code we have for opening the word docs is;
------------------------------------------------------------
Code BlockOption Explicit
Dim Wordfile, Mypath, Mydir, Myfile, MyfilePath, Myappid, Author, Yr, Check, Response, Wordapp
Sub view_document()
On Error GoTo Errorhandler 'trap errors for processing
Wordfile = "C:\Program Files\Microsoft Office\Office\WINWORD.EXE "
'Set drive
Mypath = (Left(ActiveWorkbook.FullName, 2))
'Set directory for document dependent on which sheet user is on.
If ActiveSheet.Name = "Engineering Reports" Then
Mydir = "\Engineering\Engineering Reports\Engineering Reports +600\"
ElseIf ActiveSheet.Name = "Memo's" Then
Mydir = "\Engineering\Engineering Reports\Memo's\"
ElseIf ActiveSheet.Name = "DI's" Then
Mydir = "\Engineering\Engineering Reports\DI\"
End If
'set document user wishes to open
Myfile = ActiveSheet.Cells(ActiveCell.Row, "A")
MyfilePath = Mypath & Mydir & Myfile & ".doc"
Set Wordapp = CreateObject("Word.Application")
' Set Word to be visible and call up document
With Wordapp
.Visible = True
.documents.Open MyfilePath
End With
----------------------------------------------------------
and I tried the following changes;
Code BlockOption Explicit
Dim PDFfile, Mypath, Mydir, Myfile, MyfilePath, Myappid, Author, Yr, Check, Response, PDFapp
Sub view_document()
On Error GoTo Errorhandler 'trap errors for processing
PDFfile = "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe"
'Set drive
Mypath = (Left(ActiveWorkbook.FullName, 2))
'Set directory for document dependent on which sheet user is on.
If ActiveSheet.Name = "drawings" Then
Mydir = "\drawings\drawing list\"
End If
'set document user wishes to open
Myfile = ActiveSheet.Cells(ActiveCell.Row, "A")
MyfilePath = Mypath & Mydir & Myfile & ".pdf"
Set PDFapp = ("PDF.application")
' Set Word to be visible and call up document
With PDFapp
.Visible = True
.documents.Open MyfilePath
End With
End
Since it's clear I'm in way over my head, I'm hoping that you wonderful peeps might be willing to point me in the right direction.
Many thanks
Tony.