Running A Macro Through VB
I am building a VB application which needs to automate aome processes of ER studio. I am using teh automation interface of ER studio to do this.
Now i need to run a macro (.bas file) that is located in a particular directory. Can someone suggest me a way to run this macro either by using the ER studio automation interface or any other way which uses commands outside teh scope of ER studio. Note: I know the location of the .bas file.
Thanks!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Openning Excel And Running Macro From Word - Macro
Ok - I have a DB which I export to Excel, I then run a macro to "Groom The Data". I then run word and run a Macro (MailMerge to print labels) which retrieves data from the excel spreadsheet groomed above. Everything is working fine, despite my novice knowledge of VB, but I would like to do this in a single click.
I use a command line shortcut to Launch word and automatically have it run the macro, but I still have to Launch Excel and manually run its macro first.
I did not find a command line switch to make excel launch and run a macro. Is there any way I can Lauch Word have its Macro link to excel, then launch and run the excel macros before performing the macro I have set up in word (mailmerge)
In Other Words I have working macros in Word and Excel, I want the Word Macro to force the Excel macro to run before completing the rest of its duties.
Thanks
WW
Running A Macro Sub
I am trying to create a sub that will run for an Excel file. For example:
Private Sub Wheelbase_Range_Click()
Set objExcel = CreateObject("Excel.Application")
Set objBook = Excel.Workbooks.Add
Set objSheet = objBook.Worksheets(1)
Enter Worksheet data here
objWorksheet.Run "Sub Macro1()" (This is where the error occurred)
End sub
Sub Macro1()
Contents of Macro 1 here
End Sub
There is more to the program, but these are the important parts. Any suggestions on how to run this Macro Sub for excel?
Thanks in advance,
Mark
Running A Macro
When I use macros I have only used them for Automating process with Excel.
My question is, how do I make it run a different program...
Example is: Opening up Internet Explorer, and playing a game written in java script (like astroids or something)
I know how to do key strokes, but I know nothing more for making run a program outside of ExCel
Running A Macro From VB6
Hello Everyone
This is time i am almost near to complete my project .. so far what i have done is extracted required information from a text file ,created an excel file and stored that information in sheet of excel ( with the help of VB6 form ) . now i have a macro and i want to run this macro on that very sheet of excel file , can i do it with help of VB6 ?
assume that i have my macro in a text file "macro.txt" at same path .. though i can include that code of macro anywhere in my vb6 code .. and i want to run it on sheet "Results" of Excel workbook "Working" .. placed at same directory .. how would i proceed . a lil code will be appreciable .. rest i ll try to understand though ..
Regards and Waiting
Running A Macro ???
Hi,
I have written a macro in MS Excel. I want to run it as soon as the file is opened by the user. How do I do it?
Kinjal
Macro Running Once
I've got a column of dates which a want to individually change colour depending on the current date. However, I only want the macro to run once on loading of the the worksheet - is this possible, how can I stop the end of the column becoming the active cell and is my code reasonable efficient?
TKS
Louise
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
Range("b4").Select
Do Until ActiveCell = ""
If ActiveCell > Now() + 121 Then
Selection.Font.ColorIndex = 5 'Blue
ElseIf ActiveCell > Now() + 30 Then
Selection.Font.ColorIndex = 3 'Red
ElseIf ActiveCell < Now() Or ActiveCell <= Now() + 30 Then
Selection.Font.ColorIndex = 1 'Black
End If
ActiveCell.Offset(1, 0).Range("a1").Select
Loop
End Sub
Running A Macro In Vb
I 'm trying to open a report in vb from a command button tha triggers a macro in access. The command button says to open ru a macro that opens a report. I'm Running Win XP professiona and is in an access 03 file format. When I click the comman button in the VB project. the database is locked exclusively but does not display the report or open access. This was workin for me in a access 97 format, but now I have upgraded to a newe version of access and it is not responding. Any suggestions? Di not change any references that I know of.
Code I use:
Private Sub mnuReport_Click()
Dim objAcc As Access.Application
Set objAcc = New Access.Application
objAcc.OpenCurrentDatabase ("t:sergeydb2.mdb")
objAcc.DoCmd.RunMacro "JCMacro" ' ["test" is a macro which open up a report"]
objAcc.DoCmd.OpenReport ("JCFORM"), acViewPreview
End Sub
Running A Macro
Hello all,
I'm having a tough time initiating a macro. My senario is as follows:
Private Sub CostAll_Click()
End Sub
Private Sub RSFCOST_Click()
End Sub
I want the first macro (Cost All) to be able to run the RSCOST macro. Essentially I have 4 unique macros on a sheet that each perform a seperate function, but there are cases where it would be easier to have 1 button click perform all the macros, so I'd like to just have that one button run all four unique macros.
I just can't seem to get the syntex to be right, I think it has something to do with the Private location of the macro(s).
Your help is greatly appreciated.
Adam
Error In Running Macro From VB
Hi I am new to the forum and hoping someone can help me out. I am pretty experianced in writing VBA macros and fairly new to VB but picking it up well. I want to be able to run a program that opens a .csv and runs my macro (which I know works and have been using for a long time) which is in an add in, but I want it to run in the back ground with out the user knowing Excel has opened.
Here is the code I have:
Dim obExcelApp As Object
Dim obWorksheet As Object
Dim obfile, obmac As Object
Dim blnRunning As Boolean
'Trap errors
On Error Resume Next
'Set Excel Application reference
Set obExcelApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set obExcelApp = CreateObject("Excel.Application")
blnRunning = False
Else
blnRunning = True
End If
'open .csv
Set obfile = obExcelApp.WorkBooks.Open("c:corp.csv")
'run macro
obExcelApp.WorkBooks.Open("O:HomeSpivonkaDevelopmentToolbarMacroT oolbar.xls")
obExcelApp.obfile.Select
obExcelApp.Application.Run ("Interactiveaddsheets")
When it get's to the Call portion I get an error that "a workbook must contain at least one visible worksheet"
Any suggestions? My final goal is to be able to call the macro from a batch file or something similar
Running VBA Macro Without VB Installed
I am trying to run the ffg macro in excel to get the last row index:
Function getlastrow()
Dim intlastrow
intlastRow = Application.CountA(ActiveSheet.Range("A:A"))
MsgBox intlastrow
End Function
it only runs on the machines that have VB installed.
On the ones that does not VB installed, i complains about an Object/Library not found and it points that the error is at line no. 3 of the above code.
Is there any component I need to install on these machines?
Please help
Have A Message Pop Up While Macro Is Running
At present my MS Word Macro uses the following for the Statusbar while the Macro is running.
For indx = 1 To UBound(WordArray)
If InStr(WholeDocument, LCase$(WordArray(indx))) > 0 Then
.Text = WordArray(indx)
.Execute Replace:=wdReplaceAll
End If
StatusBar = "Scanning document, please wait =" & UBound(WordArray) - indx
DoEvents
Next indx
End With
Is there a way I can have something pop up on screen saying "Macro running" and then disappear once the Macro is complete. Or, maybe someone has a better idea?
many thanks
Richi
Running A Macro Automatically
I have a spreadsheet in excel 97 with a dropdown box. Can I automatically start a macro once someone has chosen from the dropdown box?
Word Macro Running Help!
I have a macro that runs everytime a document based on the normal.dot templat is opened (using private sub document_open() ) that sets the margins to 0.5" and paper layout to landscape. I need it to only run on files that begin with a specific name (QC_A1601015_(4numbers here unique to each file).txt eg: QC_A1601015_1234.txt) so how can i put in an 'if filename = QC_A1601015_*.txt then' style command so it checks what the filename is then does the formatting if its right??
Thanks for any possible solutions!
Hide Running Macro
I hate to see excel flashing away whilst my macros run. Is there any way to hide them behind a Blank Screen (preferably with a Status bar on) until they have finished ??
Running A Macro In The Background?
Hi all,
I'm running a Word macro that needs to scan a directory for a file and notify when it arrives.
How can I have it so that it scans in the background and doesn't prevent the user from continuing to work?
Thank you.
Running A Macro From Within A Formula?
I would like to run a macro from within a formula if a certain condition is met, but have no clue how to reference the macro from inside the formula.
example:I am currently working on a spreadsheet that has 7 worksheets in it. most sheets have links to each other which ultimately go back to WS2 (the input sheet).
If a certain cell in WS2 is blank, I want to delete that row in WS3 when the cells are linked. To accomplish this, I was using a IF formula (in WS3) to determine the status of the cell (of WS2), then trying to automatically run a macro to delete the row (in WS3) of the selected cell.I am not sure of the syntax needed in the formula to activate the macro, or if I need to find another method to accomplish this.
Any assistance would be greatly appreciated!
About Stop A Running Macro
how to stop a running macro when pressing a key on keyboard !
like if a macro is running ( doing a loop) , how can i stop it when i press a key "esc" ?
bcuz that's a loop , how can i stop it without effecting other macro (API)
is that possible to achieve that ?
The Last Date A Macro Have Been Running
I ask i f any knows how can I make a simple command that show the last date for one macro (or Buttom) have been pulsed (or run).
if any know I'll appreciate it.
Progressbar During Running Of Macro
I have a couple of questions concerning this idea:
I use a template that runs a macro. This macro takes the information from a .htm file (opened in excel) and places them in the template.
While filling it I want a form to pop-up showing a progress bar.
My questions are:
1. how to use a progress bar (question stated at: general forum)
2. how to have a progress bar do it's job in a pop-up form when the macro is
run : the macro is started and a form should pop up saying: "excel sheet is
being populated" or something : how do I get the macro to continue while
at the same time having the progressbar showing progression.
and third:
3. How can I determine the progression when filling a sheet: how can I tell
when I am at 50 % and when I am done?
So ehmm VBA, winXP, MSoXP
Can anybody help me?
QC
Problem Running A Macro From The Web
I have a macro that graphs the data from a sheet onto a chart sheet in the same workbook. It works great when I run from my PC. But when I run it from the web, after the first graph, which works fine, I get the following when I try to run the graph a second time:
"run-time error 1004: Method 'Worksheets' of object '_Global' failed."
Any ideas?
Thanks,
Joe K
Running A Macro When A Cell Value Changes
Hi
hope somone can help...
How can I get a macro to run when the value in cell b1 changes.
Cell B1 contains a data validation list, and when this changes i want the spreadsheet to update its self.
Any ideas would be appreciated.
Many Thanks
Robin
Using Excel While Macro Is Running
Hi.... I have a timed process that runs every half hour. Using Doevents in a do while loop I can continue to enter data on the worksheet. However, as soon as I try to do anything in another worksheet the macro stops. Any ideas how I can run a automatic timed macro and still use the other sheets in the workbook......THanks
.....................
For i = n To x
dtEnd = timestodo(i, 1)
Do While dtEnd > Now()
DoEvents
If Range("A1") > 0 Then GoTo finishmacro
Loop
newdata = Range("B1:CZ1")
Range("B181:CZ181") = newdata
Running An Access Macro
Hello,
I have a project which is now connected to an access database using DAO. I can add, edit and delete data from tables, but I need to run some access queries from the visual basic project, but as there are several of these I have grouped them into one access macro, i would like to know how I can run this macro from the visual basic project?
Any help will be welcome,
Thanks,
JDRas
Running A Macro From Variables
I have the name of the macro and the name of the module which contains the macro in strings.
So I have 2 strings: ModuleName and MacroName
I want to run the macro, how do I do that?
It should be something like
ModuleName.MacroName
but that aint working.
Maybe this can be accomplished with VBE?
Thanks
Running A Macro In A Formula
Hi, I'm new to vb in excel and I am having a problem. I want to create a formula on a cell, so that if the value of that cell is greater than, say 29, it displays a MsgBox letting the user know of their mistype.
I have done it using a macro, but can't workout how to do macro commands in a formula.
It will be used for timecode refferences: i.e. the user will input a timecode (e.g. 09:59:59;30) into a cell, and if the last 2 numbers, (in this case 30) are greater than 29, it will tell the user.
Cheers
D.
Conditional Running Of A Macro
Hi, all
I'm looking for a procedure that will automatically start a macro on condition that the current date is a workday (Monday - Friday), and if so, it should start the macro at a given time.
I know that I can do something like:
If range("A1") >= 2 And range("A1") <= 6 Then
Call MacroABC
But, how is it possible to do this with out making a reference into a workbook? How can one trigger a macro under such conditions?
Hope you can help.
Running A Powerpoint Macro...
Hello,
I cant figure out how to run a powerpoint macro from vb.net
I open the file and then need a macro to be ran.
here is the code i use to open the file:
ppapp = CreateObject("powerpoint.Application")
With ppapp
.Visible = True
ppPres = ppapp.Presentations.Open(FileName:="c:
atiomodelnewchanges.ppt")
End With
************************************
This works fine but I cannot find a command to run a macro that is part of this file...
thanks
Running A Macro Through A VB Script
I have a VB program which runs through a list of excel workbooks and Opens them up, runs a macro, saves and closes the workbook, the problem I am having is that I don't know what the bit of code is needed to run the macro on the excel workbooks.
Can anyone offer any suggestions. Thanks very much
Simon
Running An Access Macro
Hi
I have an application that runs on SQL Server. The Data Reporting tool in VB being rather limted does not allow me to create reports exactly as I would like so I have linked the tables in Microsoft Access and created Queries and Reports and macros to run the reports. The thing is (and its a big thing!!) I don't know how to code in VB to run the macro and supply the parameter for the report. I think it has something like / x main/
If anyone can help I would be very grateful
Thanks
Running An Excel Macro From Within VB
Hi all,
I need to run a silly little macro from a command button in VB.
This is the macro from excel:
Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 21/01/2002 by MAGrosoft
'
' Keyboard Shortcut: Ctrl+q
'
Range("A1:A6").Select
Selection.Copy
Workbooks.Open Filename:="C:My DocumentsBook2.xls"
Range("A1").Select
ActiveSheet.Paste
Range("C5").Select
End Sub
its just a cut and paste thingy.
what I want is to be able to call that macro from VB
Any suggestions as to how I do that?
could I dim variabvles in this macro (VBA) so that I can change the selections and filenames, and then pass the parameters from VB across to the VBA macro?
Thanks in advance
Macro Running In Background
Hi,
I have a macro running which takes around 10-15min to complete the task.
But, when the macro runs I cannot do any other task or any work on any other excel sheets.
Is there any code or function by which when my macro is running in background I can perform other task in other excel sheets or use other application.
Thanks,
Malay
Running A Macro/form
I have currently the following code written in VB:
Private Sub command1_click()
Dim appAccess As Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "c: empd1.mdb"
appAccess.DoCmd.RunMacro "Macro1"
End Sub
I run the program click the command1 button and nothing happens, not even an error message.
It should open access and run the macro right?
The macro works fine if I run it directly from Access.
Is there any special configuration I must do in the access macro to allow it be run on VB?
if someone could give me a hand I would be very gratefull.
Joao
I also tried to open a form but again nothing hapened!
Macro Not Running Under CommandButton
In Excel I have been using VB to write macros. I have several Macros running under one CommandButton and all of them work except the following. Running on it's own, not using the command button, this macro runs and does what I want it to. But within the total application, it will not run. By pressing the button I want this macro to open up another existing workbook, populate certain cells, and then retrieve a numerical answer from a given cell back into the original spreadsheet. From that point I want the second workbook to close and not save the changes to it. If you can see what I am doing wrong please help.
Public Sub Macro21()
'
' Macro21 Macro
' Macro recorded 8/13/2003 by Glen Wiebe
' Selects the first cell in the range and copies it
Workbooks("Mysheet.xls").Activate
Range("E13").Select
ActiveCell.Copy
'Set a flag to check to see if target spreadsheet is already open
'If open it activates it, if not open it opens and activates it
flag = True
For Each w In Workbooks
If w.Name = "Othersheet.xls" Then
flag = False
End If
Next w
If flag = True Then
Workbooks.Open "C:Othersheet.xls"
End If
Range("F13").Select
Application.CutCopyMode = False
ActiveCell.Copy
Workbooks("Mysheet.xls").Activate
'Pastes only the value into the cell
With Worksheets("Sheet1")
.Range("H96").PasteSpecial Paste:=xlPasteValues
End With
'Closes all workbooks except this one
For Each w In Workbooks
If w.Name <> ThisWorkbook.Name Then
w.Close savechanges:=False
End If
Next w
End Sub
Running Excel Macro
Hi,
How can I call an Excel macro and pass a parameter to it from my vb code? I used
Set ApExcel = CreateObject("Excel.sheet")
ApExcel.Application.Run "PERSONAL.xls!getStats"
but how can I change the code to pass in a parameter?
Thanx!
Running Excel Macro From Word
i have 2 macros, one in word, which manipulates the document and saves the file as an excel file on my desktop, and another macro in excel which manipulates the data and saves it as a file with no extension.
i for the word macro to run the excel macro after it is finished. i have tried several things but it doesnt seem to work, (i do have the references set properly to accept excel commands)
can anyone help with the code to complete this??
any help would be greatly appreciated
Running Macro Template + Security
Hi Everybody,
My first question is I have different templates with different macros.
I have my application calling word three times.
Now i want to load one template (or run only macro1) when word loads for the first time, second time i want to run another template (or run macro2) when word loads, and third time i dont want any feature like that, just plane word. Can anybody tell me how to do it.
(I was thinking of making different batch files which loads different templates in the application directory before calling word. I am not sure is that a right approach)
Also another question is about the security related to using this macros.
how can we make the macros very very secure so that we can use that in the bank environment. Is there any way to put this macros on the server and client can install it as a component in the word.
Does anybody know about any good articale, website which gives me some info about it.
Thanks
Samir
Running An Access Macro From Excel
I have a macro set up in Access which merges various excel spreadsheets . What I want to do is include the right VB code in my excel macro so that once it has finished with the spreadsheet it automatically opens access and runs the macro in there....can this be done ??
Running Macro When Workbook Opens
How do I get this to work when I open my workbook in Excel 2000?
Does it go on the sheets page or the module page?
Is the code correct? I don't think the first line is
correct.
I am trying to limit access on a sheet to only certain
cells.
I got the bit from With to End With from Microsoft help
screen
Worksheets("HP Calculator").Activate
With Worksheets(1)
.EnableSelection = xlUnlockedCells
.Protect Contents:=True, UserInterfaceOnly:=True
End With
Excel Event Macro's Not Running
Anyone know what would cause my event macros to stop running. It seems like they work for a few minutes then quit. I put a break in the code and the macro window doesn't pop up. Any ideas??
Running An Access Macro In Excel
I'm trying to run an Access Macro (Macro1) using the Visual Basic Editor in Excel. The code i'm using is:
Code:
Sub RunAccMacro()
Dim oAccess As Object, oDB As Object
Set oAccess = CreateObject("Access.Application")
oAccess.Visible = True
oAccess.OpenCurrentDatabase "J:UPSUPS.mdb"
oAccess.Run "Macro1"
End Sub
This opens the Access Database ok but then I get the runtime error:
Run-time error '2517':
Microsoft Access can't find the procedure 'Macro1.'
Any ideas why this is happening?
Matt
Running A Macro While A Document Is Protected
Hello,
I have a document where people add their names to a list and then hit a button that runs a macro. This macro takes their name and copy/paste it to the end of the list.
The thing is that I don't want people playing with the name list so I protected the sheet and left only the 4 cells in whitch they can add the info needed. Once the button is pressed, since the sheet is protected, I can't copy/paste the info to the list.
Is their a way to add a command in a macro that will unprotect the sheet (whitout showing what the password is), run the macro and then protect the sheet with the same password (and still not show it)???
Thanks!!!
EXCEL - How To Prevent A Macro From Running
I'm writing this macro to open a number of Excel workbooks and copy some rows to a Word document.
Everything works fine but for two glitches:
1) After copying a row containing a large amount of text, Excel prompts me to either clear the ClipBoard or keep its contents when it tries to close the workbook, though it is supposed to be hidden. Can this check be turned off before closing a workbook?
2) Some of the workbooks I'm processing have a Workbook_Open macro attached to them that in turn refers to an external .xls. Is it possible to prevent this macro from running?
Edit by Moderator:
Please post Excel questions in the Excel board.
Thank you.
Running A Excel Macro From VBScript
Can anyone help with this ?
I am trying to Run a Macro in my Excel Sheet using VBScript So Far I have tried the Following
Code:
'This is a VBScript.
Dim strPath
Dim oXLA
strPath = "MyExcel.xls!CreateData"
set oXLA = CreateObject("Excel.Application")
oXLA.Run strPath
Set oXLA = Nothing
This is no good. I tried some Solution I found after doing a Google Search those did not Help Also.
Please point me in correct direction.
Thanks
Datta.
Running Macro From Another Workbook With Out Saving
i have a program that processes excel workbook, the input is any excel workbook (*.xls), how can i run a macro i have on another excel workbook to the selected (input) workbook with out saving the macro in the input?
Running A Macro On A Specific DAY && Time
I know about the On Time Method... However can this method be modified to run on a specific Day as well as time...say Wednesday @ 3:00pm...Or is there another method that covers both Day & Time automation...
Thanks...
Refreshing Excel While Running A Macro!?!?
Hi,
I've created a macro for excel which communicates with a database server called Proserver. This server can relay data from 2 PLC's to a PC. The macro collects data from the PLC's via this server and displays it in Excel. This works fine except for one thing: the PLC's store a huge amount of data and therfore collecting the data needs a reasonably amount of time. During this time several processes can't take place. Therefor I divided the data in 10 blocks and send 1 block at a time. My problem is that when I receive the 10 blocks, in between two blocks I want to write and refresh the data of the last received block on my Excelscreen. However I can't get it working. When I place a breakpoint in my macro at the point where it's ready to receive the next block, it works. My Excel screen is refreshed and the data is displayed. When I step over the breakpoint, the next block is displayed. But without the breakpoint it just rumbles through the macro untill all blocks are received and then the screen is refreshed. And I need the screen to be refreshed afther every received block. It seems to me that during macro runtime Excel itself hangs.
I tried the refresh commando but it won't work. Can anyone help me?
Thanks in advance,
Pieter
Netherlands
Selecting A Range While A Macro Is Running
I have a vba macro that transfers data between two spreadsheets.
The macro works; however, it would be better if the user could select the range to transfer while the macro was running.
Currently, before the macro is run, 1) the source sheet must be selected 2) the source range on the source sheet must be selected 3) the destination sheet must be selected.
Code:
FunctionTransferData(lRowDestination as Long, nCol as Integer, strSource as String) as Boolean
'lRowDest is the destination Row in the Destination Worksheet
'nCol is the column being transferred
'strSource is the path to the source workbook
Dim appXL As Excel.Application
Dim lRow as Long
Dim lRowDest as Long
Dim lRowFirst as Long
Dim lRowLast as Long
Dim objSourceWB As Excel.WorkBook
Dim objSourceWS As Excel.Worksheet
Dim objDestinationWS As Excel.Worksheet
Dim rngSource as Excel.Range
Set appXL = Excel.Application
'Debug.Print objWB.Name
Set objDestinationWS = appXL.ActiveSheet
Set objSourceWB = appXL.Workbooks(strSource)
Set objSourceWS = objSourceWB.Worksheets("Data")
objSourceWS.Activate
Set rngSource = appXL.Selection '<--------requires the selection to be made before the macro is run
lRowFirst = rngSource.Row
lRowLast = lRowFirst + rngSource.Rows.Count - 1
lRow Dest = lRowDestination
For lRow = lRowFirst to lRowLast
objDestinationWS.Cells(lRowDest, nCol) = objSourceWS.Cells(lRowDest, nCol)
lRowDest = lRowDest + 1
Next lRow
objDestinationWS.Activate
Set rngSource = Nothing
Set objSourceWS = Nothing
Set objSourceWB = Nothing
Set objDestinationWS = Nothing
Set AppXL = Nothing
End Function
Is there a way to select a range while a macro is running?
It would seem execution must be paused, the selection made and the execution continued.
Any help would be appreciated.
|