473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Is it possible to create macros in an excel file during runtime and run the same?

Hi,

I am pretty new to VBA.

I wanted to know if there is a way to create a macro in an excel file and run the same, all in runtime?

I am using C++ to dump few integer values into an excel sheet and from that i want to create chart automatically.

Also i need to send the range for chart.

Regards,
Pratvik
Jan 10 '11 #1
1 1456
Stewart Ross
2,545 Expert Mod 2GB
Hi. It is possible to do what you ask, but it is more normal to manipulate the Excel sheet directly from VBA by using Excel automation instead of creating macros (i.e. VBA code routines) on the fly within the workbook itself.

Also, it is simpler to create and format the chart in advance in an Excel workbook with sample data based on a table using the same row sequence and fields as you would expect to export.

Using the prepared file all you have to do is open the file using VBA code and export the latest data to the table (for example by using the CopyFromRecordset method), then save and close the file. This avoids the need to create the chart in code (which can take a fair bit of effort if the chart requires complex formatting).

-Stewart
Jan 12 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Cathy Bro | last post by:
I have been able to create and Active Server Page that when I link to it will ask if I want to download to an excel file which I do want. It works well, but there is one thing that I haven't been...
2
by: anon | last post by:
I am new to vbnet and wonder if it is possible to get the data from my datagrid and save it to an excel file so that different reports can be saved at different times for further analysis at a...
7
by: Martin | last post by:
I have a situation where I'm displaying some information in a table on a web page. I've given the user the ability to make several different "queries" and show different sub-sets of the data. I...
1
by: AMeador | last post by:
I need to have my c# application actually create a new Excel file from an Excel template file, and then update a bunch of fields in the new file. Can this be done? I am using VS.NET 2003 EA Edition...
3
by: sandycat05 | last post by:
Hello all, I am a new Perl programmer. Below is the beginnings of a code that I am using to manipulate an Excel spreadsheet via Perl using win32::OLE. However, what I'd like to do is the following:...
0
by: Jim Heavey | last post by:
I create a console application. This application creates a simple Excel File. I move this application to a server. I use the .Net Configuration utility and grant the application full access...
27
by: jeniffer | last post by:
I need to create an excel file through a C program and then to populate it.How can it be done?
1
by: SagarDoke | last post by:
I have a txt file. I want to add the data from that file into the excel file using java. That data is delimited by spaces as follows: 1 Sagar Doke Address Roll No. City 2 ABC ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.