C-DLL-VBA-EXCEL strings

Hello, I'm trying to connect excel to a C dll library (call C dll from
excel through the VBA). It works well for returning integer and double
values (see simple example below), but I can't seem to get it to
return strings. I am using MinGW gcc (so basically only C) to
construct my dll, so I don't have access to BSTR and other cpp like
objects/functions... Is there a way to make the C dll return strings
to excel? Thanks

DLL.c
#ifdef BUILD_DLL
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __declspec(dllimport)
#endif
EXPORT int __stdcall add2(int num){
  return num + 2;
}

COMPILE mydll.dll
c:\> gcc -c -DBUILD_DLL dll.c
c:\> gcc -shared -o mydll.dll dll.o -Wl,--add-stdcall-alias

IN VBA:
Private Declare Function add2 Lib "c:/mydll" _
   (ByVal num As Long) As Long
0
franco1 (1)
6/24/2009 3:42:09 PM
excel 39879 articles. 2 followers. Follow

0 Replies
613 Views

Similar Articles

[PageSpeed] 34

Reply:

Similar Artilces:

DDE in Excel
Hi, I'm trying to help my department make use of the DDE function of excel. Basically, this means opening a worksheet with specific formulas referencing a trade platform client they have installed. Then they should be able to select the 'Transition Formula Entry' option under the Advanced Menu and the prices should automatically update. At least that is how it works on my computer. I can't figure out what settings they have different than me... ...

Shared Excel File
Shared Excel files on the department directory do not seem to close properly. The subsequent user gets a message when they attempt to open a file that the last person to use it is still in it, even though the former user doesn't have it open. Bill ...

Message
I recently totally re-installed all of my programs as well as Windows XP, when I re-installed Office 2003, and downloaded my old settings, using the Save My Settings wizard, I now get two "error" messages, although the box does not say error. I get a box that says Microsoft Office Outlook and then the following (part of which I am going to truncate) C:\documents and settings\Tom.....\Microsoft shared\geography\mpoai9.dll is not a valid office add-in. I also get a similar one as shown in the subject line above. I can NOT get rid of these. I have tried the repair, as wel...

How to build a project in Visual C++.net developed in Visual C++ 6
Hi, I am Nageshwar. I have developed a project in VC++ 6.0 and OpenGL. I have installed VC++.net in my system. When I compile and build the same code in VC++.net environment, I am getting errors. I have used fstream.h to read and write to files. But this header file is showing errors in VC++.net. I have used iostrea.h header. This is also showing erros. I think I need to use a different version of headers. Please suggest me how to recover from these errors. Which header file I have use instead of fstream.h header? etc., Thanks for all who help me.. Awaiting an early response, Nageshwar ...

VBA Compile error when converting to Access 2007
I have converted a database from Access 2003 to 2007, but the VBA project will not compile/run. The problem seems to be with the DAO, but when I go into Tools References and add the MS DAO 3.6 object library back in I get an error saying 'Name conflicts with existing module, project, or object library'. The code it falls over on is: Dim MyIndex As Index Set MyIndex = MyTable.CreateIndex("PrimaryKey") With MyIndex .Primary = True 'falls over on this section .Required = True .Unique = True ...

Saving Chart Names in Excel 2007
I saved an XLS file as an XLSX file without performing a conversion. After making changes to the workbook, the chart names will not save, they just revery back to the default "Chart1", "Chart2", etc. names. I followed these steps to change the names to no avail: When you create charts, Microsoft Office Excel assigns a default name to each chart by using the following naming convention: Chart1, Chart2, and so on. However, you can change the name of each chart to make it more meaningful to you. Click the chart that you want to rename. This displays the Chart Tools, ad...

Inability to Open Workbooks Without Excel Open
Hi, The only way I can open an existing Excel file is through the application itself. I cannot open a workbook using Windows Explorer, through Start -> Documents, and so forth. When I try using these methods, I am presented with a blank Excel window, without any visible information. Any ideas of how to proceed? Thanks in advance, Henry http://www.officearticles.com/excel/troubleshooting_microsoft_excel.htm ************ Anne Troy VBA Project Manager www.OfficeArticles.com <hstockbridge5@hotmail.com> wrote in message news:1132248432.902401.204520@g43g2000cwa.googlegroups.com.....

Excel trying to open files no longer existing..
I don't know what I did, but now when I open Excel it tries to open 2 or 3 files that no longer exist. How do I stop this? I believe it had something to do with Tools -> Folder Options -> File Types in that area of Explorer, but I can't figure out what to do to make it work fine again. Shawn Give us some more detail. You say Excel "tries to .....". Exactly what do you see that makes you think that is what is happening? If Excel is commanded to open a file that doesn't exist, you will get an error message. Do you get an error message? If y...

How to combine Excel 2002 files and remove duplicate records?
I’ve recently took over a task at my job of managing some Excel files. I am using Excel 2002. There are several Excel files that need to be combined into one file however, if I do this, I will have some duplicate records that I will have to delete. The only way I know how to do this is to copy and paste and then look for duplicate records manually and delete them as I find them. Is there an easier way to do this? Thank you for you support and help. Yes, there is. I would use VBA to do that job, but I need more info. When you say there are duplicate records, exactly what is duplicated? ...

C: Drive documents and setting expansion
Whenever I, Right Click Start then click "Explore", I get an expansion of the my user ID folders. Now, I rarely us "Documents and Settings" and would like to have it expand differently. What do I need to change so that can happen?? Thanks.. Bruce A. Julseth wrote: > Whenever I, Right Click Start then click "Explore", I get an > expansion of the my user ID folders. Now, I rarely us "Documents and > Settings" and would like to have it expand differently. > > What do I need to change so that can happen?? 1. You could ...

Entering within cells in Excel on a Mac
Does anyone know when using a Mac, how to enter to the next line within an excel cell without going it going to the next cell? I know for a PC it is Alt and enter. Nicko Wrote: > Does anyone know when using a Mac, how to enter to the next line withi > an > excel cell without going it going to the next cell? I know for a PC i > is Alt > and enter. COMMAND+OPTION+RETURN Hope this helps -- Domeni ----------------------------------------------------------------------- Domenic's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1078 View this thread: ...

Create timeline for 2500 B.C. to 100 B.C.?
Visio only allows me to create timeline for after 1900 AD. Can I use Visio to create a timeline for 2500 BC to 100 BC? Visio's Divided timeline has exactly what I need except I can not enter BC as the start and end time. And Visio always require end time to be greater than the start time. Any suggestion on how I can do this in Visio? You're not going to be able to use the timeline because the code is linked to the system clock (only goes back to 1900). You'll have to use the vanilla shapes that come with visio. Al "Little Black Sheep" <Little Bl...

Visual C++ to read Strings from Serial Port
Hi. I'm doing a project using Visual C++ to read data from Serial Port. My program needs to do *something* when it receives specific data. For eg, if the program receives "Alarm 1 Zone 4", it will do something. The data received will be variable in length. My questions: 1) Any recommendations for the serial Comm Class for Visual C++? 2) How can i compare the data i receive from serial to the specific messages i'm looking for, eg data types, size of data types, limitations & etc.? Thanks. Any comments are highly appreciated. Leng As far as the serial part goes, it i...

Slow charting hotfix for Excel 2007
A hotfix is available from Microsoft to remedy the slow charting problem in Excel 2007. http://support.microsoft.com/kb/938538/en-us Unfortunately, you can't download it directly yet and instead have to call Microsoft support. I think they said it would be rolled out officially in the first service pack for Office 2007. But, if you explain your problem (slow charting) and reference the knowledge base article as the solution, they will email you the hotfix and not charge you the outrageous support call cost. I've installed the hotfix on my computer and although charting is not as fa...

Formatting excel
Often when i double click on the extreme Left hand row, the column hieght gets adjusted to its contents. However i have found that this does not apply to few of the cells.. For eg. in my case the cells having data in BOLD were not being adjusted to its height(even if content of these cells is having less data limited to 6 words). I have used the word-wrap feature throughout the sheet. i had to manually drag the cell hieght in such cases... I have over 4000 rows filled in my excel sheet. is there any way to adjust the column hieght of the cells automatically by selecting all rows & d...

Reference a table field in VBA
I've got a current Access project that I'm building. The source files are downloaded reports and imported through VBA functions. I'm timestamping the source files during the import process. I now need to reference that particular timestamp (it will only be one timestamp) and use it as a variable in an export function later on in my VBA. Here is an example of my datapoint Sourcetable: sourcetable_1 Field: Run_Dte Variable of Run_Dte needed Export: DoCmd.RunSQL ("SELECT A, B, C INTO [Excel 8.0;Database=C:\QC_PREVIEW_" & Format(Run_Dte, "yyyy-mm-dd hhmms...

Out of the Box 200 Excel Reports
Hi, Does any one know from where I can download out of the Box 200 Excel based reports for MS Dynamics GP10? Thanks It's built in. Tools > Setup > System > Reporting Tools Setup. I was kind of disappointed in them. They are just the Smart Lists as far as i can tell. I'm using them to create Excel dashboard reports. "Naseer Farooqi" wrote: > Hi, > > Does any one know from where I can download out of the Box 200 Excel based > reports for MS Dynamics GP10? > > Thanks > As a starting point though they are faster th...

Excel Spreadsheet
I have large database on Excel but the search & sort will not work correctly over a certain size ?? is there a preset limit rto how much it can sort ..if so how do i alter Paul The most likely explanation is that the whole area is not being selected prior to the search. Try again, making sure that the whole range is selected before you start the sort. Andy. "Paul Nudds" <Paulelthill@brinternet.com> wrote in message news:00bb01c37ec3$278bc620$a301280a@phx.gbl... > I have large database on Excel but the search & sort will > not work correctly over a certain s...

VBA to open all xls file and...
Hello all, I'm just getting into VBA. I usually work with Macs and have som scripting knowledge using Applescript. :eek: I'm after a script to open all xls files in a folder and resave each a file type 'text (Macintosh)' with the same file name as each that opened. I've had a fair try but am having trouble getting to grips with the VB code :confused: Would want to include all nested folders as well but want to addres that separately so I can get my head round the code! Thanks in advance : -- Message posted from http://www.ExcelForum.com Without sub-directories S...

C++ : Is it lots harder than c# and VB
Hi everyone, I learned Java whilst at university and have taught myself c# and VB.net. I think I am ok at it. I was thinking, these languages will probably be bigger in the future so I better get ready for them. But then, I also realised that COM is still quite important and so is C++. So I thought I better just try and have a look at C++ and COM. And now I'm scared. So my question is - why does C++ look so much harder than c#? For example : 1. The methods all have really stupid names that are hard to descern a function from. 2. You need to think about pointers and cleaning up ...

Size of excel components
Is there any Excel function or add-on that will display for me the size of the components of a spreadsheet, e.g. macros, images, named ranges unused cells, lookups etc. I am faced with an Excel application that asks me to email megabyte-sized spreadsheet, and I need to audit it to see where on could cut down the size ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com Not that I'm aware. Maybe you could remove an item, save as new name, note the size. Reopen the origina...

Excel merge columns
Hallo, I have two different lists. List A with three columns: name, first name, email address and list B with 7 columns: name, first name, Street, City, Post Code, Counrty. The list B containes the names of list A. How do I merge these two different lists, so that the e-mail address appears as separate column of List B? Myrto Myrto - If the rows are identical, you could insert a column in list B titled E-mail, then go to List A, Copy to e-mail column, and paste it in list B. Just be sure that you are pasting it in the right row. Carole O "Myrto" wrote: > Hallo, >...

VBA turing up on the web...excel transfer...
Ok, here's the deal! I want to take my database/spreadsheet from excel and place it on the web with interactivity - I have done this so far.....what the problem is: I have macros in VBA programing that is not going with the excel pages onto the web...why? Is this going to be easier if I start from scratch in FrontPage to be able to control this program fully? Please help...I can't find anyone that knows....:-( ** Posted via: http://www.ozgrid.com Excel Templates, Training, Add-ins & Software! Free Support at http://www.ozgrid.com/forum/ ** ...

Excel Needs to Close
Frequently, when turning on my computer, I will get the message something like "Excel has encountered a problem and needs to close." I may not have used Excel for days and it definitely was not open when the computer was turned off. Any clues? Do I have a problem? Ed, Look for an Excel file, or Excel itself, in your Startup folder (Start - All programs). Scan for viruses. -- Earl Kiosterud www.smokeylake.com Note: Top-posting has been the norm here. Some folks prefer bottom-posting. But if you bottom-post to a reply that's already top-posted, the thr...

Excel charts and Word docs
In Office 2003, how do I import an excel table into a word doc? In Ms Word go to Insert - Object - Create from File and select the xls file that contains your table. "Frustrated" wrote: > In Office 2003, how do I import an excel table into a word doc? Copy the range in Excel, switch to Word, and paste. Word puts the Excel data into a Word table. - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ "Frustrated" <Frustrated@discussions.microsoft.com> wrote in message news:90F...