![]() |
pass workbook name to sub
Hi,
In my addin I'm opening file through workbooks.open. Till now it's allright. But when I want to pass workbook to other subs I'm receiving error "subscript out of range". Here is my code: #addin Sub RaportPlat() Dim fd As FileDialog Set fd = Application.FileDialog(msoFileDialogOpen) With fd .Filters.Add "Raport płatności", "*.xls", 1 .Show End With Workbooks.Open Filename:=fd.SelectedItems(1) Copy_Rows_Wejscie_Nieuslugi (fd.SelectedItems(1)) passing workbook to sub: Sub Copy_Rows_Wejscie_Nieuslugi(WorkbookName As String) 'workbooks(WorkbookName).Activate Dim RngCol As Range Dim i As Range Workbooks(WorkbookName).Worksheets("wejscie nieuslugi") = ActiveSheet here i'm receiving error. How can I resolve it, please? TIA Przemek |
pass workbook name to sub
Hi Przemek,
Probably because the name is path and name. Try Copy_Rows_Wejscie_Nieuslugi (Activeworkbook.Name) -- HTH RP (remove nothere from the email address if mailing direct) "Przemek" wrote in message oups.com... Hi, In my addin I'm opening file through workbooks.open. Till now it's allright. But when I want to pass workbook to other subs I'm receiving error "subscript out of range". Here is my code: #addin Sub RaportPlat() Dim fd As FileDialog Set fd = Application.FileDialog(msoFileDialogOpen) With fd .Filters.Add "Raport płatności", "*.xls", 1 .Show End With Workbooks.Open Filename:=fd.SelectedItems(1) Copy_Rows_Wejscie_Nieuslugi (fd.SelectedItems(1)) passing workbook to sub: Sub Copy_Rows_Wejscie_Nieuslugi(WorkbookName As String) 'workbooks(WorkbookName).Activate Dim RngCol As Range Dim i As Range Workbooks(WorkbookName).Worksheets("wejscie nieuslugi") = ActiveSheet here i'm receiving error. How can I resolve it, please? TIA Przemek |
All times are GMT +1. The time now is 03:33 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com