Excel Application.run Error 1004
Contents |
Forums Excel Questions Application.Run causing Run Time Error 1004 Results 1 to 5 of 5 Application.Run causing Run Time Error 1004This is a discussion on Application.Run causing Run Time Error 1004 within the Excel Questions forums, run time error 1004 excel 2010 part of the Question Forums category; I have an Addin (call it Does.xla) which operates
Run Time Error 1004 Application Defined Or Object Defined Error
on a Workbook (call it Mike.xls). When I make changes to ... LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg
Run Time Error 1004 Excel 2013
this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools Show Printable Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Dec 3rd, 2010,06:18 PM #1 BrighterLater Board Regular Join Date Sep
Microsoft Visual Basic Runtime Error 1004 Excel 2013
2005 Location Maidstone, UK Posts 112 Application.Run causing Run Time Error 1004 I have an Addin (call it Does.xla) which operates on a Workbook (call it Mike.xls). When I make changes to the function of Does.xla I sometimes need to make changes to Mike.xls. At present the code to automatically make these changes lives within Does.xla, but it is getting bigger and bigger. What I would like to do is to store run time error 1004 excel 2007 these update routines as external .vba files. I then want to import them, run then and then remove them. For test purposes my macro to mport looks like this. Code: Attribute VB_Name = "Fred" Option Explicit Sub fred() MsgBox "Hello world" End Sub And the code to do the business in DOES.xla is Code: Sub Test() Dim VBProj As Object Dim myFileName As String Dim ii As Integer Dim sTemp As String Dim sname As String Dim path As String Dim sMacro As String myFileName = "C:\AP_Pro\accounts\freddy.vba" Set VBProj = Nothing On Error Resume Next ' oMyWb is of type Workbook (Global which is why not Dimd here ' and is open (oMyWB.name delivers its name below) Set VBProj = oMyWb.VBProject On Error GoTo 0 If VBProj Is Nothing Then MsgBox "Security Issue" Exit Sub End If ' Import the module and find it's name VBProj.vbcomponents.Import myFileName ii = VBProj.vbcomponents.Count sTemp = VBProj.vbcomponents(ii).Name sMacro = oMyWb.path & "\" & oMyWb.Name & "!" & sTemp ' Produces error message ' Run Time Error '1004' ' The macro 'C:\AP_Pro\Accounts\mike.xls!Fred' cannot be found Application.Run sMacro ' Just in case something has changed the order of componetnts ' we loop through looking for our imported macro ' before removing it For ii = 1 To VBProj.vbcomponents.Count If VBProj.vbcomponents(ii).Name = sTem
here for a quick overview of the site Help Center Detailed answers to any questions you might runtime error 1004 vba excel 2010 have Meta Discuss the workings and policies of this site About run time error 1004 method range of object _global failed Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads run time error 1004 excel macro with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million http://www.mrexcel.com/forum/excel-questions/513171-application-run-causing-run-time-error-1004-a.html programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error when use Application.run to run a macro from another workbook up vote 0 down vote favorite I need to run multiple scenarios in a excel model. In the current model, each scenario has to be load manually, and http://stackoverflow.com/questions/32000143/error-when-use-application-run-to-run-a-macro-from-another-workbook each run takes over 3 hours. I also need to save the model result in a new workbook. I'm writing a macro to allow scenarios automatically load in the model, run, and save as a new workbook. My code is below. The problem is when it goes to the code line "Application.run ... ", Run time error 1004: Application defined or object defined error. Please help! Private Sub CommandButton1_Click() Dim ScentoRun, Path, N As String Dim DestCom, Target As Range Dim SCount, x As Integer Path = "F:\" SCount = Workbooks("Scenarios to Run").Worksheets("Sheet1").Cells(6, Columns.Count).End(xlToLeft).Column For x = 1 To SCount Workbooks.Open Filename:=Path & "The Model.xlsm" Workbooks("Scenarios to Run").Worksheets("Sheet1").Columns(x).Copy Workbooks("The Model").Worksheets("Scenarios").Columns(6).PasteSpecial ScentoRun = Workbooks("The Model").Worksheets("Scenarios").Range("F6").Value Application.DisplayAlerts = False Workbooks("The Model").SaveAs Filename:=Path & ScentoRun, FileFormat:=52 Application.DisplayAlerts = True Workbooks(ScentoRun).Worksheets("Results").Range("F8") = Workbooks(ScentoRun).Worksheets("Scenarios").Range("F6") Workbooks(ScentoRun).Activate N = Workbooks(ScentoRun).name Application.Run "'N'!loadScenario" '----- ERROR HERE Workbooks(ScentoRun).Save Workbooks(ScentoRun).Close (True) Next x End Sub excel vba excel-vba share|improve this question edited Aug 23 '15 at 19:30 Brian Tompsett - 汤莱恩 3,091132775 asked
have a number of different macros, each in a separate workbook. Now I want to create a macro in a new workbook that will open each workbook one at a time and run the macro contained in that workbook. My http://www.pcreview.co.uk/threads/run-macro-in-another-workbook-error-1004.3972336/ first attempt at this yielded the following error: Run-time error '1004': Cannot run the macro 'report1'. http://www.vbaexpress.com/forum/showthread.php?15871-Solved-Run-time-error-1004-(macro-export-import-) The macro may not be available in this workbook or all macros may be disabled. (The macro in the target workbook is defined as Public Sub Report1() and the one function in the code module is also defined as Public Function Find_col()) I did some experimenting and created two other workbooks with very simple macros (msgbox with text to show me what was executing) and error 1004 then called them from the same workbook that I was starting to develop. I was able to execute both of the simple macros but still not able to execute the macro I really want to run. What should I look for in the target macro that is different from the two macros that I can successfully run? John Keith John Keith, Feb 21, 2010 #1 Advertisements John Keith Guest On Sun, 21 Feb 2010 15:15:39 -0700, John Keith <> time error 1004 wrote: >What should I look for in the target macro that is different from the >two macros that I can successfully run? > After playing around with this problem I finally found what the issue was. It seems that if the filename of the other workbook that has the macro I want to run has a space charater in it then the runtime error is produced. Seems strange that a valid filename would cause this error but after removing all the spaces everything worked as expected. John Keith John Keith, Feb 23, 2010 #2 Advertisements Dave Peterson Guest Are you using application.run to run the macro? If yes, then maybe... dim wkbk as workbook set wkbk = workbooks.open(filename:=yourpathandfilename, readonly:=true) application.run "'" & wkbk.name & '!macronamehere" Those apostrophes are important. John Keith wrote: > > On Sun, 21 Feb 2010 15:15:39 -0700, John Keith <> wrote: > > >What should I look for in the target macro that is different from the > >two macros that I can successfully run? > > > After playing around with this problem I finally found what the issue > was. It seems that if the filename of the other workbook that has the > macro I want to run has a space charater in it then the runtime error > is produced. Seems strange that a valid filename would cause this > error but after removing all the spaces everything worked as expected.
VBA Code & Other Help Excel Help Solved: Run-time error 1004 (macro export/import?) If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 5 of 5 Thread: Solved: Run-time error 1004 (macro export/import?) Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 11-01-2007,05:12 AM #1 Lester View Profile View Forum Posts View Blog Entries View Articles VBAX Regular Joined Oct 2007 Location Sheffield Posts 63 Location Solved: Run-time error 1004 (macro export/import?) Hello again, Thanks for the help thus far...I have another query. I recorded the following macro, then exported it for use with other excel files: Sub CalculateCostandSales() ' ' CalculateCostandSales Macro ' Macro recorded 01/11/2007 by Les ' ' Keyboard Shortcut: Ctrl+g ' Application.Run "'Temp Company Data.xls'!ImportLookUp" Sheets("Sheet6").Select Application.Run "'Temp Company Data.xls'!ProcessSalesAndCosts" End Sub Formatting tags added by mark007 I can import it into the new excel file ok, but the problem is that it still contains references to the original excel file 'Temp Company Data.xls' where the macro was recorded. Hence, I get the following '1004' run-time error. 'Temp Company Data.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct. The debugger then highlights the line Application.Run "'Temp Company Data.xls'!ImportLookUp Formatting tags added by mark007 Does anyone know how to make the macro 'generic' so it can work in any excel file that imports it? Many thanks for your help. Lester. Reply With Quote 11-01-2007,05:28 AM #2 xl