View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default 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