Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
2 votes
0 answers
86 views

Mac native function (ObjC / LibC) to call function with arguments

I maintain a 'modern' VBA library on github stdVBA. The library provides a high level wrapper on top of many low level functions in Windows OS. Mac compatibility is desired and the main obstruction is ...
Sancarn's user avatar
  • 2,784
0 votes
1 answer
134 views

Return a Variant from a c dll to Excel VBA on macos

In Paulo Bueno's project https://github.com/buenop/MinXL he returns a Variant from a C++ dll, e.g. Declare PtrSafe Function IncrementArrayBy _ Lib "/Library/Application Support/Microsoft/...
DangerMouse's user avatar
0 votes
0 answers
111 views

Best way to return a dynamically sized array from C dll to VBA

I have read a few posts on this now but none quite answer what I am after. I am writing a C dll (not C++) to read a specific type of data file, and return the data to vba for display in excel. For ...
bgarrood's user avatar
  • 487
0 votes
0 answers
184 views

Pass String from VBA to C DLL to Modify as a Parameter and Return

My journey learning about C DLL's and their interaction with VBA continues. The setup is I want to pass a string to the C DLL as a parameter, have the DLL modify the string, and return a return code ...
michaeka's user avatar
2 votes
0 answers
400 views

Unable to run C coded DLL in Excel VBA

I have a Windows 10 64-bits, Office 2013 32-bits and using MinGW64. I followed instructions from https://www.transmissionzero.co.uk/computing/building-dlls-with-mingw/ I checked other answers ...
Fabio's user avatar
  • 21
1 vote
2 answers
435 views

Close a txt file opened by another process in Windows programmatically

I am looking to force close a txt file that is opened by another process. Looking for suggestions, ideas on how this can be accomplished, and the caveats involved. Python solution would be great, ...
Jesh Kundem's user avatar
0 votes
1 answer
51 views

I would like to replicate this nested for loop I have in c in an excel vba

Note:I'm aware that this explanation is confusing but when you look at the code I posted it will make a lot more sense. Feel free to suggest any edits. I'm trying to recreate a a nested for loop I ...
Sam's user avatar
  • 7
2 votes
0 answers
59 views

Prevent Excel file from remember old DLL data. DLL Hell?

I've made simlpe C DLL: void msgbox(long n) { char tmp[255]; sprintf(tmp, "%ld", n); MessageBoxA(0, tmp, "DLL Message", MB_OK | MB_ICONINFORMATION); } void DLL_EXPORT ...
ingwarus's user avatar
  • 412
1 vote
1 answer
131 views

Malloc error in excel called .exe library

I'm using office 365 in 64 bit, with Windows 10 OS. I compile my .exe file with Visual Studio 2017 Community. Each time I met malloc() function, it report a violation of memory access. It is nearly ...
Shore's user avatar
  • 1,003
0 votes
2 answers
327 views

How to call a C DLL from a VBA application and return an array?

I'm developing a a VBA application which writes and reads a serial port through a C DLL. In the code below I have managed to return a value into the VBA code in the form of a string. What I want to ...
Ian's user avatar
  • 3
4 votes
2 answers
9k views

Use DLL in excel-vba

i would love to know how to declare and use a dll in vba. I have a code written in C and i would like to use some data from an excel sheet to test my c-code. How is it possible? Many thanks in advance
Mohamed Azzam's user avatar
2 votes
1 answer
808 views

Error accessing 64bit DLL function

I have created a 64bit DLL file using Microsoft Visual Studio 2015. Visual C --> Win32 Project. The code for squareMain.c is as follows : long _stdcall square(long a) { return a*a; } The code ...
Pranav Bhagwat's user avatar
2 votes
2 answers
954 views

How can I receive "char *d" from DLL in VBA(Excel Visual Basic)?

Now I'm trying to get a char string as the below c function. This is a C function of DLL, char _stdcall *fmt_hex(long long num, int nbits, char *d) { sprintf(d, "0x%0*llX", (nbits - 1) / ...
grander3's user avatar
  • 181
0 votes
0 answers
57 views

editing table using vba

I'm trying to edit the following table (the left one in the picture): I have columns of x, y, test name, pass/fail (0 if pass and 1 if fail), and "firstFAIL" column. For each pair of x and y I have to ...
Maya.R's user avatar
  • 21
2 votes
1 answer
981 views

Send a BSTR string written in a C DLL to Excel

I am trying to send a BSTR string written in a C DLL to Excel. Problem: Excel VBA receives the BSTR from the C DLL. I can see the BSTR in the VBA Intermediate window and debug window. If I try to ...
12avi's user avatar
  • 495
0 votes
1 answer
290 views

How do I build a Type to pass to a DLL function that takes a pointer to a struct with an array inside?

I have a C DLL that defines a struct and a function that takes a pointer to it: header: typedef struct { double arr[10]; double anotherParam; double result; } CStruct_t; int __stdcall ...
Ronan Paixão's user avatar
1 vote
0 answers
110 views

Unexpected Results When Returing BSTR from DLL to Microsoft Excel VBA Application

I am writing a VBA extension in C, from what I have read VBA uses BSTR, which is just a WCHAR* with a length prefix. I have a function: __declspec(dllexport) VB_STRING _stdcall getStr() { return ...
Jacob H's user avatar
  • 876
2 votes
2 answers
973 views

Excel VBA script crashes when calling a DDL function written in C, which returns a string BSTR

I'm using Code::Blocks to write a DLL in C which I intend to use in a Winbatch script but for the moment I'm testing it using Excel VBA. The moment the VBA script runs the DLL getVersion() function ...
JanWillemT's user avatar
1 vote
1 answer
406 views

How to print a variable length string of a single character

I have a need to print a variable number of a given character in conjunction with my formatted output. I was looking for something similar or equivalent to the VBA function String(num, char), but ...
Jack Galt's user avatar
1 vote
2 answers
241 views

Excel VBA not working well with C dll for decimals - works fine with integers

I have a problem that really stumps me. Ultimately, I think that the problem could very well be down to my lack of knowledge about C programming for Windows or how to properly work between C and VBA. ...
mdv's user avatar
  • 39
1 vote
2 answers
4k views

C++ to VBA (Excel)

So, basically, in Excel, I have 4 columns of data (all with strings) that I want to process, and want to have the results in another column, like this (nevermind the square brackets, they just ...
MikeAscended's user avatar
0 votes
3 answers
56 views

checking and setting variable, efficiently

I am new to programming and have a simple question: is there a "better" or more efficient way of doing this... if (x != 0) { y = x; } or if (getMethod() != null) { value = getMethod(); } I'm ...
Sammy's user avatar
  • 35
4 votes
1 answer
214 views

How to Pass value as dynamic array from vb to c

I have below declaration: Type routineStruct man As String * 3 number As String * 5 End Type Type vbToC sch As String * 4 routine(0 To 10000) As routineStruct End Type vbfun As vbToC Now ...
Prateek Mondal's user avatar
0 votes
1 answer
498 views

LPARAM as pointer to VBA variable

I'm building a very simple win32 console application which is coded in C and compiled using Visual Studio 2010/2013. It will have a message queue running in a separate thread from the main one. The ...
Chris D's user avatar
  • 371
2 votes
1 answer
871 views

copy multiple pdf files data to excel in different worksheets

I have created a vba script to copy all data from multiple pdf files and paste in a excel in different tabs with the same name of the pdf files. Problem is its copying data from pdf files and pasting ...
Striker's user avatar
  • 247
1 vote
1 answer
115 views

How to print a C BSTR in Excel 16 for Mac with VBA?

I have a C function which returns a BSTR like "Hello world" and in Excel 11 I can call this function to print the string with the msgbox vba function. With Excel 16, I only have an returned empty ...
TuDa's user avatar
  • 87
2 votes
1 answer
1k views

Implementing Rosseta Code FFT into VBA Excel

I attempted to implement the FFT Rosetta Code into VBA excel. I was unable to reconstruct the same output data exactly as written in the Rosetta Code. At first I thought it was type conversion ...
linuxfreebird's user avatar
-6 votes
2 answers
330 views

Translate this simple C code to VBA

I am looking to print an output that constitutes a string and a float. For example, I calculated the density of a box using D = Mass/Volume. I would now like to generate an output saying "The density ...
Kmanchel's user avatar
4 votes
1 answer
1k views

DLL compiled from C source code. Not able to use in excel VBA. File not found error

I have written a function in C (for some bitwise operations on 64-bit) and I want to use that function in my excel vba macro. I used steps described here to create a DLL file using cygwin (64-bit). ...
fonzie's user avatar
  • 43
0 votes
1 answer
219 views

VBA and dlls in C: Strategy for more responsive and controllable Excel performance?

I have an Excel workbook that another (3rd party. Not under my control) application pushes data onto. I have written various VBA functions that are triggered via an Worksheet.Change event when certain ...
blagstar's user avatar
0 votes
1 answer
330 views

Avoid basic rand() bias in Monte Carlo simulation?

I am rewriting a monte carlo simulation in C from Objective C to use in a dll from VBA/Excel. The "engine" in the calculation is the creation of a random number between 0 and 10001 that is compared to ...
blagstar's user avatar
1 vote
1 answer
64 views

Problems comparing integers to hardcoded values in a dll called from VBA

I am about to transfer a project I have written in Applescript and Objective C to Excel/VBA/dll. I have started with the Objective C functions that I want to place in a dll and call via VBA. First of ...
blagstar's user avatar
2 votes
0 answers
99 views

C dll call from VBA : strange behavior

I write a C dll compiled in 64 bits with the following function: in the .h : _FF_EXPORT double __stdcall add(double a, double b); in the .c : double __stdcall add(double a, double b) { return a+...
Istopopoki's user avatar
  • 1,762
0 votes
1 answer
48 views

MS Access: Search through Table for the same part of the String

I am trying to loop through Column Values inside my Table. I have a register form, which provides the user with UNIQUE ID, based uppon his information. For example: Country = Austria Each user that ...
David Kasabji's user avatar
1 vote
1 answer
576 views

Porting a VBA Type / C struct to a Python ctypes.Structure: array of strings with fixed length

I am trying to port a piece of VBA code to Python. This effort includes calling a function in a Windows DLL. The function requires a pointer to a C struct (in VBA, they are called "Type") as a ...
s-m-e's user avatar
  • 3,691
1 vote
2 answers
175 views

Logic for grouping similar parameters

I am trying to figure out the best logic for grouping parameters within a certain tolerance. It's easier to explain with an example... Task1: parameter1=140 Task2: parameter1=137 Task3: parameter1=...
dreed75's user avatar
  • 115
2 votes
1 answer
310 views

C function in Excel 64 bit does not work as a worksheet function but works well in VBA

I am writing a 64 bit Dll in C which is then used in Excel 64 bit, and I am following a sample project from https://sites.google.com/site/jrlhost/links/excelcdll. The example is simple. We write a ...
eric.lx's user avatar
  • 23
1 vote
1 answer
970 views

calling a dll function from MS access

hi I'm trying to call this function in ms access vba. It just throws up bad calling convention. I tried to recompile access but zilch. I have called dll functions before so perhaps I’ve missed ...
user3256802's user avatar
1 vote
0 answers
734 views

Getting IDispatch interface pointer for running application (e.g. Excel)

Suppose I can write (in pseudocode) ptr = CreateObject("Excel.Application") And doing that creates an instance of excel.exe and gives me the dispatch pointer for the Excel.Application interface. Is ...
Bathsheba's user avatar
  • 234k
1 vote
1 answer
215 views

Declare a variable Registry in VBA?

New to VBA here. We can decare a variable as "Register" in C/C++ for very-very frequently accessed variable, ex- Loop iterator variables. Does similar system exist in Visual Basic for Application. I ...
Ramu Bhai's user avatar
1 vote
1 answer
578 views

Call an executable of OCaml or C from VBA code

Under Ubuntu I have coded a very simple ml.ml in OCaml: let () = print_string "hello world, in OCaml\n" And a simple c.cin C: #include <stdio.h> main() { printf("hello world, in C\n"); ...
SoftTimur's user avatar
  • 5,462
1 vote
2 answers
439 views

Handling BSTRs on MacOSX in C

I've written some code in C for converting strings passed from VBA, when the C code is called from VBA from a MacOSX dylib. I got some good hints here, and since I only care about ASCII strings I've ...
Martin's user avatar
  • 146
1 vote
3 answers
1k views

Return string to VBA in MacOSX

I'm currently writing a C dynamic library in MacOSX, the functions are then used in Excel (2011) using the VBA, e.g.: Declare Function TestF Lib "path_to_lib:mylib.dylib" Alias "test" (ByRef res As ...
Martin's user avatar
  • 146