Hi
I have Project.xlsm file when userform of "Project.xlsm" initialised it opens one xlsx file. "StarServices.xlsx"
there is also worksheet name "Dir-File-Names" form where the "StarServices.Xlsx" is opened
Having coded in UF "Project.xlsm" Queryclose to close the xlsx
Subscript out of Range Erro i get. How can i prevent this error. Have gone thru many threads. but still unsuccessful
Also i want to clear isome of its range with clearContents and ClearFormats when closing with queryclose
Any possibilty ?
coding in Project.xlsm
Project.xlsm (userformQueryclose)
Thanks NimishK
I have Project.xlsm file when userform of "Project.xlsm" initialised it opens one xlsx file. "StarServices.xlsx"
there is also worksheet name "Dir-File-Names" form where the "StarServices.Xlsx" is opened
Having coded in UF "Project.xlsm" Queryclose to close the xlsx
Subscript out of Range Erro i get. How can i prevent this error. Have gone thru many threads. but still unsuccessful
Also i want to clear isome of its range with clearContents and ClearFormats when closing with queryclose
Any possibilty ?
coding in Project.xlsm
Code:
Private Sub UserForm_Initialize()
Dim fpath As String ',
Dim picpath As String, pic As Picture
With ThisWorkbook.Sheets("Dir-File-Names")
fpath = .Range("A3").value & ":\" & .Range("B3").value & "\" & .Range("C3").value & "\" & "StarServices.xlsx"
Workbooks.Open Filename:=fpath
End With
End Sub
Project.xlsm (userformQueryclose)
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Dim fpath As String
Dim wBk As Workbook
With ThisWorkbook.Sheets("Dir-File-Names")
fpath = .Range("A3").value & ":\" & .Range("B3").value & "\" & .Range("C3").value & "\" & "StarServices.xlsx"
End With
On Error GoTo 0
[COLOR=#ff0000][B]'''Error Observed Here
[/B][/COLOR] Set wBk = Workbooks(fpath)
If Application.ActiveWorkbook.Name = wBk.Name Then
wBk.Close False
End If
End Sub
Last edited: