PC Review


Reply
Thread Tools Rate Thread

Attempting to call a sub from another wb using a Userform option b

 
 
OffDev
Guest
Posts: n/a
 
      30th Nov 2009
Please assist.

I have an userform that has several options button each calls a sub proc
from another workbook
I am getting run-time error 1004 Method Run of object_Application failed
when I click on the button when the other workbook close .

When the workbook is open I am getting run-time error 1004 Cannot run the
macro wbMain.xlsm!cmdOpenfile. The macro may not be available in this
workbook or all macros may be disabled.but with a different reason.
My macros options are enabled and has trusted access.

I am baffled because the code is very simple:

Application.run "wbMain!subproc"

Thanks
Offdev
 
Reply With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      30th Nov 2009
Am I guessing correctly that wbMain is a workbook variable?

If so then try the following
Application.Run wbMain.Name & "!subproc"

Or maybe you have just used wbName as an example of your workbook name in
which case if your workbook name has any spaces in the name then enclose the
workbook name in single quotes.

Application.run "'wb Main'!subproc"



--
Regards,

OssieMac


"OffDev" wrote:

> Please assist.
>
> I have an userform that has several options button each calls a sub proc
> from another workbook
> I am getting run-time error 1004 Method Run of object_Application failed
> when I click on the button when the other workbook close .
>
> When the workbook is open I am getting run-time error 1004 Cannot run the
> macro wbMain.xlsm!cmdOpenfile. The macro may not be available in this
> workbook or all macros may be disabled.but with a different reason.
> My macros options are enabled and has trusted access.
>
> I am baffled because the code is very simple:
>
> Application.run "wbMain!subproc"
>
> Thanks
> Offdev

 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      30th Nov 2009
An afterthought.

If wbMain is a workbook variable then if there are any spaces in the
workbook's name then you will also need to include the single quotes in the
line of code as per one of the following examples.

Application.Run Chr(39) & wbMain.Name & Chr(39) & "!subproc"

Application.Run "'" & wbMain.Name & "'" & "!subproc"

--
Regards,

OssieMac


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Access is attempting to call SQL Server before BeforeDelConfirm =?Utf-8?B?RC1Tb21lb25l?= Microsoft Access Form Coding 1 29th Mar 2007 04:45 PM
call a userform =?Utf-8?B?SmFuaXM=?= Microsoft Excel Programming 3 31st Aug 2006 12:32 AM
Macro to call-up UserForm =?Utf-8?B?TXIuIEcu?= Microsoft Excel Worksheet Functions 0 24th Aug 2006 09:24 AM
How to call a sub from UserForm Module Myles Microsoft Excel Programming 2 31st Mar 2006 04:40 AM
Using cell name to call userform pjbur2005 Microsoft Excel Programming 4 15th Feb 2006 03:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:34 PM.