Mr_Adams
Active Member
- Joined
- Oct 7, 2002
- Messages
- 475
I use the code below to print a portion of a sheet. My problem is that the area always changes
The $A$476 should be the first cell in that column that contains "HEA"
The "536" in $F$536 is the last row that contains data.
There are conditional formats all the way down to row 1,000 but not data
<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> CommandButton1_Click()
<SPAN style="color:#00007F">Dim</SPAN> strCurrentPrinter <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, strNetworkPrinter <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
strNetworkPrinter = GetFullNetworkPrinterName("Adobe PDF")
<SPAN style="color:#00007F">If</SPAN> Len(strNetworkPrinter) > 0 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#007F00">' found the network printer</SPAN>
strCurrentPrinter = Application.ActivePrinter
<SPAN style="color:#007F00">' change to the network printer</SPAN>
Application.ActivePrinter = strNetworkPrinter
ActiveSheet.PageSetup.PrintArea = "$A$476:$F$536"
ActiveSheet.PrintOut <SPAN style="color:#007F00">'print something</SPAN>
<SPAN style="color:#007F00">' change back to the previously active printer</SPAN>
Application.ActivePrinter = strCurrentPrinter
ActiveSheet.PageSetup.PrintArea = ""
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
Obviously there is a function also that finds the full network printer name, I didn't think it was important, because my issue is the print area. Everything else works fine. If you need it let me know and I will post it
Thanks in advance
The $A$476 should be the first cell in that column that contains "HEA"
The "536" in $F$536 is the last row that contains data.
There are conditional formats all the way down to row 1,000 but not data
<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> CommandButton1_Click()
<SPAN style="color:#00007F">Dim</SPAN> strCurrentPrinter <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, strNetworkPrinter <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
strNetworkPrinter = GetFullNetworkPrinterName("Adobe PDF")
<SPAN style="color:#00007F">If</SPAN> Len(strNetworkPrinter) > 0 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#007F00">' found the network printer</SPAN>
strCurrentPrinter = Application.ActivePrinter
<SPAN style="color:#007F00">' change to the network printer</SPAN>
Application.ActivePrinter = strNetworkPrinter
ActiveSheet.PageSetup.PrintArea = "$A$476:$F$536"
ActiveSheet.PrintOut <SPAN style="color:#007F00">'print something</SPAN>
<SPAN style="color:#007F00">' change back to the previously active printer</SPAN>
Application.ActivePrinter = strCurrentPrinter
ActiveSheet.PageSetup.PrintArea = ""
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
Obviously there is a function also that finds the full network printer name, I didn't think it was important, because my issue is the print area. Everything else works fine. If you need it let me know and I will post it
Thanks in advance