auto printing

J

JV

Good day to all,

I have a file wherein all the list of hotel equipment
files are listed

ex.
col. A B
HVAC-Apartment HVAC Hotel
A-06-B-PU1.xls B-LG-EF.xls
A-06-CH1-P.xls H-01-FA1.xls
A-07-SA1-EF.xls Chiller-1.xls

In my previous inquiries, they give me a macro that when i
press the files in the above list it will automatically
open the respected files.

What i would like to have now is a macro that whenever i
click a file, it will print automatically.

Any help at this time.

jv
 
R

Ron de Bruin

I think a macro assign to a button or use a shortcut is better?

Try this for the file in the activecell I use the path C:\

Sub test()
Dim wb As Workbook
If Dir(ActiveCell.Value) <> "" Then
Application.ScreenUpdating = False
Set wb = Workbooks.Open("c:\" & ActiveCell.Value)
wb.PrintOut
wb.Close False
Application.ScreenUpdating = True
End If
End Sub
 
R

Ron de Bruin

Sorry I have a typo

Use this

Sub test()
Dim wb As Workbook
If Dir("c:\" & ActiveCell.Value) <> "" Then
Application.ScreenUpdating = False
Set wb = Workbooks.Open("c:\" & ActiveCell.Value)
wb.PrintOut
wb.Close False
Application.ScreenUpdating = True
End If
End Sub
 
G

Guest

Ron,

I got a compile error.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As
Range, Cancel As Boolean)

Sub test()
Dim wb As Workbook
If Dir("E:\Backups\jv\S-
Thomas\PPM\Hotel\Refrigeration\Ref-Updated\" &
ActiveCell.Value) <> "" Then
Application.ScreenUpdating = False
Set wb = Workbooks.Open("E:\Backups\jv\S-
Thomas\PPM\Hotel\Refrigeration\Ref-Updated\" &
ActiveCell.Value)
wb.PrintOut
wb.Close False
Application.ScreenUpdating = True
End If
End Sub

Can you locate where i made a mistake?

Can you tell exactly thru a step by step way to make it
work. Im not familiar with macro.

It suppose to be a double click only to a certain file and
it will automatically print.

jv
 
R

Ron de Bruin

This is working for me

This in the Sheet module

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Value = "" Then Exit Sub
test
End Sub


And this in a normal module

Sub test()
Dim wb As Workbook
If Dir("c:\" & ActiveCell.Value) <> "" Then
Application.ScreenUpdating = False
Set wb = Workbooks.Open("c:\" & ActiveCell.Value)
wb.PrintOut
wb.Close False
Application.ScreenUpdating = True
End If
End Sub
 

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