Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
pass variable from one workbook to another calebjill Excel Discussion (Misc queries) 2 January 28th 09 07:38 PM
Pass workbook name to ActiveX DLL (VB6) meldrum_scotland Excel Discussion (Misc queries) 0 August 8th 08 06:07 PM
Pass an argument to Excel workbook dorothy lo Excel Programming 2 April 22nd 04 04:05 AM
<Pass the Torch from a Closing Workbook Alex J Excel Programming 2 January 7th 04 12:42 PM
<Pass the Torch from a Closing Workbook Alex J Excel Programming 0 January 6th 04 03:56 AM


All times are GMT +1. The time now is 02:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright Š2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"