Jagat Pavasia
Active Member
- Joined
- Mar 9, 2015
- Messages
- 406
- Office Version
- 2021
- Platform
- Windows
Dear sir,
I have 2 Sheet in my excel workbook.
First sheet name is "Account" and another name is "Print".
I have put Below VBA in sheet named "Print"
And I put link of command button in sheet named "Account" and click on it,
then I got Error 400.
If i put link of command button in sheet named "Print" and click on it then it work as I want.
But I want to put command Button in sheet "Account".
what can i Do ?
I have 2 Sheet in my excel workbook.
First sheet name is "Account" and another name is "Print".
I have put Below VBA in sheet named "Print"
VBA Code:
Sub Print_Jangad()
'
' Print_Jangad Macro
'
'
Set mynetwork = CreateObject("WScript.network")
mynetwork.SetDefaultPrinter "Brother QL-800"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = ""
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0.196850393700787)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 300
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = 329
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
Range("A35:F44").Select
Selection.PrintOut Copies:=1, Collate:=True
Set mynetwork = CreateObject("WScript.network")
mynetwork.SetDefaultPrinter "Samsung SCX-3200 Series"
End Sub
And I put link of command button in sheet named "Account" and click on it,
then I got Error 400.
If i put link of command button in sheet named "Print" and click on it then it work as I want.
But I want to put command Button in sheet "Account".
what can i Do ?