jcutler
09-19-2018, 04:49 PM
As the title states I get a compile error on
NewWB.TopMargin = 0.3
".TopMargin =" is highlighted in blue as shown above when the error message is displayed. All I am trying to do is open workbook file located on a server and copy and paste it in another worksheet in another workbook and set the page setup the margin values where the worksheet is to be pasted to. Here is the full code below.
Option ExplicitPrivate Sub Workbook_Open()
Dim sPath As String, sFile As String
Dim wb As Workbook
sPath = "Z:\GRP\EVERYONE\FORMS\"
sFile = sPath & "F-103-04 Exh I-Solid Dose Usage Record-Rev001.xlsx"
Set wb = Workbooks.Open(sFile)
Call OpenSDUsageRecord
Sub OpenSDUsageRecord()
Dim NewWB As Worksheet
Set NewWB = Application.Workbooks("ChattemPackaging.xlsm").Worksheets("Solid Dose Usage Record")
ActiveWorkbook.Copy NewWB
NewWB.TopMargin = 0.3
NewWB.LeftMargin = 0.2
NewWB.BottomMargin = 0.3
NewWB.FooterMargin = 0.2
NewWB.RightMargin = 0.2
NewWB.HeaderMargin = 0.2
End Sub
Thank You
NewWB.TopMargin = 0.3
".TopMargin =" is highlighted in blue as shown above when the error message is displayed. All I am trying to do is open workbook file located on a server and copy and paste it in another worksheet in another workbook and set the page setup the margin values where the worksheet is to be pasted to. Here is the full code below.
Option ExplicitPrivate Sub Workbook_Open()
Dim sPath As String, sFile As String
Dim wb As Workbook
sPath = "Z:\GRP\EVERYONE\FORMS\"
sFile = sPath & "F-103-04 Exh I-Solid Dose Usage Record-Rev001.xlsx"
Set wb = Workbooks.Open(sFile)
Call OpenSDUsageRecord
Sub OpenSDUsageRecord()
Dim NewWB As Worksheet
Set NewWB = Application.Workbooks("ChattemPackaging.xlsm").Worksheets("Solid Dose Usage Record")
ActiveWorkbook.Copy NewWB
NewWB.TopMargin = 0.3
NewWB.LeftMargin = 0.2
NewWB.BottomMargin = 0.3
NewWB.FooterMargin = 0.2
NewWB.RightMargin = 0.2
NewWB.HeaderMargin = 0.2
End Sub
Thank You