15-06-22 11:28 AM
Answered! Go to Answer.
20-06-22 11:38 PM
Dim sw, dw As Object
Dim ss, ds As Object
Dim excel, sheet, source, destination, cells, cell As Object
Const xlCellTypeVisible As Int32 = 12
Try
sw = GetWorkbook(Handle, Source_Workbook)
dw = GetWorkbook(Handle, Destination_Workbook)
ss = GetWorksheet(Handle, Source_Workbook, Source_Worksheet)
ds = GetWorksheet(Handle, Destination_Workbook, Destination_Worksheet)
sw.Activate()
ss.Activate()
excel = ss.Application
sheet = excel.ActiveSheet
cell = excel.ActiveCell
If Source_Range="" Then
cells = sheet.Cells.SpecialCells(xlCellTypeVisible)
Destination_Range = "A1"
Else
cells = sheet.Range(Source_Range).SpecialCells(xlCellTypeVisible)
End If
cells.Select()
source = excel.Selection
source.Copy()
cell.Select()
dw.Activate()
ds.Activate()
sheet = excel.ActiveSheet
cell = excel.ActiveCell
destination = sheet.Range(Destination_Range)
destination.Select()
sheet.Paste()
cell.Select()
My.Computer.Clipboard.Clear()
Success = True
Catch e As Exception
Success = False
Message = e.Message
Finally
sw = Nothing
ss = Nothing
dw = Nothing
ds = Nothing
excel = Nothing
sheet = Nothing
source = Nothing
destination = Nothing
cells = Nothing
cell = Nothing
End Try
Here, just to explain you I have added one line at the top to the original code: Const xlCellTypeVisible As Int32 = 12
and then I am using it at places like: cells = sheet.Cells.SpecialCells(xlCellTypeVisible)
and cells = sheet.Range(Source_Range).SpecialCells(xlCellTypeVisible)
These lines help me to tell the code that it only needs to pick up the visible cells on the screen apart from the entire range which the original code did by default.
Testing For Solution:
Now, publish your action and then use all the actions of the same business object where you have done the changes in your process studio while interacting with the excel file in order to avoid any exceptions. I have a sample process studio workflow shown below:
20-06-22 03:55 PM
20-06-22 11:38 PM
Dim sw, dw As Object
Dim ss, ds As Object
Dim excel, sheet, source, destination, cells, cell As Object
Const xlCellTypeVisible As Int32 = 12
Try
sw = GetWorkbook(Handle, Source_Workbook)
dw = GetWorkbook(Handle, Destination_Workbook)
ss = GetWorksheet(Handle, Source_Workbook, Source_Worksheet)
ds = GetWorksheet(Handle, Destination_Workbook, Destination_Worksheet)
sw.Activate()
ss.Activate()
excel = ss.Application
sheet = excel.ActiveSheet
cell = excel.ActiveCell
If Source_Range="" Then
cells = sheet.Cells.SpecialCells(xlCellTypeVisible)
Destination_Range = "A1"
Else
cells = sheet.Range(Source_Range).SpecialCells(xlCellTypeVisible)
End If
cells.Select()
source = excel.Selection
source.Copy()
cell.Select()
dw.Activate()
ds.Activate()
sheet = excel.ActiveSheet
cell = excel.ActiveCell
destination = sheet.Range(Destination_Range)
destination.Select()
sheet.Paste()
cell.Select()
My.Computer.Clipboard.Clear()
Success = True
Catch e As Exception
Success = False
Message = e.Message
Finally
sw = Nothing
ss = Nothing
dw = Nothing
ds = Nothing
excel = Nothing
sheet = Nothing
source = Nothing
destination = Nothing
cells = Nothing
cell = Nothing
End Try
Here, just to explain you I have added one line at the top to the original code: Const xlCellTypeVisible As Int32 = 12
and then I am using it at places like: cells = sheet.Cells.SpecialCells(xlCellTypeVisible)
and cells = sheet.Range(Source_Range).SpecialCells(xlCellTypeVisible)
These lines help me to tell the code that it only needs to pick up the visible cells on the screen apart from the entire range which the original code did by default.
Testing For Solution:
Now, publish your action and then use all the actions of the same business object where you have done the changes in your process studio while interacting with the excel file in order to avoid any exceptions. I have a sample process studio workflow shown below: