CFMI
asked on
MS Excel 2010 VBA compile error
Experts,
I receive a compile error in the below VBA on the statement, “Const FULL_PATH As String = SSreportBuilder.xls.UserFo rm1.SSFile Name”. The code is an object in Excel trying to run an enclosed macro with a selected workbook. The Names include:
Spreadsheet: SSReportBuilder.xls
Form: UserForm1
Text Box named – SSFileName
Please provide your assistance and thank you in advance.
Private Sub cmdOK_Click()
cmdOK.Enabled = False
Dim app As Application
Dim wbTarget As Workbook
Dim strReturnedValue As String
Dim SSFileName As String
Dim strArg As String
If Risk = -1 Then
'========================= ========== ========== ===
'Supply/Change fullname
'========================= ========== ========== ===
Const FULL_PATH As String = SSreportBuilder.xls.UserFo rm1.SSFile Name
'========================= ========== ========== ===
'Set a reference to the new instance
'========================= ========== ========== ===
Set app = New Application
With app
.Visible = True
.WindowState = xlMinimized
'========================= ========== ========== ===
'Open Workbook
'========================= ========== ========== ===
Set wbTarget = app.Workbooks.Open(SSFileN ame)
'========================= ========== ========== ===
'Run selected macro
'========================= ========== ========== ===
Application.Run "SSreportBuilder.xls!McrRi sk"
'========================= ========== ========== ===
'Close Workbook and Kill the instance
'========================= ========== ========== ===
Workbooks(SSFileName).Clos e savechanges:=False
wbTarget.Close False
.Quit
MsgBox "The Workbook has updated Formats"
End With
cmdOK.Enabled = False
Else
MsgBox "Please select a Macro"
End If
End Sub
I receive a compile error in the below VBA on the statement, “Const FULL_PATH As String = SSreportBuilder.xls.UserFo
Spreadsheet: SSReportBuilder.xls
Form: UserForm1
Text Box named – SSFileName
Please provide your assistance and thank you in advance.
Private Sub cmdOK_Click()
cmdOK.Enabled = False
Dim app As Application
Dim wbTarget As Workbook
Dim strReturnedValue As String
Dim SSFileName As String
Dim strArg As String
If Risk = -1 Then
'=========================
'Supply/Change fullname
'=========================
Const FULL_PATH As String = SSreportBuilder.xls.UserFo
'=========================
'Set a reference to the new instance
'=========================
Set app = New Application
With app
.Visible = True
.WindowState = xlMinimized
'=========================
'Open Workbook
'=========================
Set wbTarget = app.Workbooks.Open(SSFileN
'=========================
'Run selected macro
'=========================
Application.Run "SSreportBuilder.xls!McrRi
'=========================
'Close Workbook and Kill the instance
'=========================
Workbooks(SSFileName).Clos
wbTarget.Close False
.Quit
MsgBox "The Workbook has updated Formats"
End With
cmdOK.Enabled = False
Else
MsgBox "Please select a Macro"
End If
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER