RichardP1978
Registered User.
- Local time
- Today, 02:15
- Joined
- Nov 14, 2006
- Messages
- 89
OK,
I have spent all morning trying to work this out to no avail.
This is some code I use,
Dim obj As Object
Set obj = GetObject("f:\clientdatabase\templates\ChartTemplates.xls")
obj.Application.Visible = True
obj.Windows(1).Visible = True
obj.Application.ScreenUpdating = True
obj.Application.Goto "TobaccoLogTitleBar"
obj.Application.ActiveCell = "Tobacco Log for " & Forms![frmclientmain]![FirstName] & " " & Forms![frmclientmain]![Surname]
obj.PrintOut
The problem I have got is that the print command prints the entire workbook out, I have tried various alternatives using the code from this link to provide inspiration, but I am fresh out. http://www.rondebruin.nl/print.htm#Print
I would like the code to insert the relevant data in to the cell (which it does) and then print the active worksheet, not the whole workbook which is what it is doing. I dont mind if I have to code it to print the worksheet by its name, or through some 'activesheet' style command. If it cant be done whereby you can single out a worksheet within a workbook, so be it, but I would prefer to have all my charts in one file to keep tracking them easier.
I would like it to close the book without saving changes and close excel, although I would imagine this would be very similar to the word option.
Hope you can help.
I have spent all morning trying to work this out to no avail.
This is some code I use,
Dim obj As Object
Set obj = GetObject("f:\clientdatabase\templates\ChartTemplates.xls")
obj.Application.Visible = True
obj.Windows(1).Visible = True
obj.Application.ScreenUpdating = True
obj.Application.Goto "TobaccoLogTitleBar"
obj.Application.ActiveCell = "Tobacco Log for " & Forms![frmclientmain]![FirstName] & " " & Forms![frmclientmain]![Surname]
obj.PrintOut
The problem I have got is that the print command prints the entire workbook out, I have tried various alternatives using the code from this link to provide inspiration, but I am fresh out. http://www.rondebruin.nl/print.htm#Print
I would like the code to insert the relevant data in to the cell (which it does) and then print the active worksheet, not the whole workbook which is what it is doing. I dont mind if I have to code it to print the worksheet by its name, or through some 'activesheet' style command. If it cant be done whereby you can single out a worksheet within a workbook, so be it, but I would prefer to have all my charts in one file to keep tracking them easier.
I would like it to close the book without saving changes and close excel, although I would imagine this would be very similar to the word option.
Hope you can help.