|
-
Dec 26th, 2007, 07:29 PM
#1
Thread Starter
Junior Member
Including a API in VBA(excel)
Somewhat new to VBA, I have experience in C++. Anyways I am trying to connect to a server through an API.
I have instruction on how to include some .dll files when using visual basic editor.
However, I am using excel and VBA, I assume all the code is going to be the same, however I dont know how to add these .dll files. The graphical interface isn't the same. Can't I do this all within the source code?
-
Dec 27th, 2007, 12:01 AM
#2
Re: Including a API in VBA(excel)
the graphical interface between vb6 and excel's vba is the same. Go into the vba macro editor and create a module. Put vb6-style declarations in the module.
-
Dec 27th, 2007, 12:25 AM
#3
Re: Including a API in VBA(excel)
Welcome to the Forums.
If you have some dlls that you need to reference in Excel's VBA then go to the Tools > References... menu and select the dlls you need to add.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 27th, 2007, 02:59 PM
#4
Thread Starter
Junior Member
Re: Including a API in VBA(excel)
hey, ya i had tried that, i cant seem to add any .dlls. It says I cannot add a reference to the specified file. Now I just noticed that they are in a vb.net folder. Perhaps this could be the problem?
bu then again some dlls that arent in the folder cannot be added either.
-
Dec 27th, 2007, 03:42 PM
#5
Re: Including a API in VBA(excel)
It depends on the dll. A .NET dll will definately not be reference-able if its not designed to be COM visible. Other dlls will depend on their code. There are C++ and ActiveX dlls. Is there a specific dll your trying to ref?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 27th, 2007, 05:52 PM
#6
Thread Starter
Junior Member
Re: Including a API in VBA(excel)
Yes they are API's to connect to a brokerage server. They do have an ActiveX file that I can properly refrenece. However, when I include that, and then try to run a function should be defined by that library, it cannot find that function. It's not a big deal i think I have found a way around it. Thank you though.
-
Dec 28th, 2007, 12:48 AM
#7
Re: Including a API in VBA(excel)
What was your wayu around it? Something specific to that app?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 28th, 2007, 02:47 PM
#8
Thread Starter
Junior Member
Re: Including a API in VBA(excel)
Yes they have a template excel file that connects to the app. I am going to write some vba code that interacts with this excel file and its spreadsheets instead.
I have one question though, I wrote a code that copies the value of a cell into another cell, then moves down 1 cell, and does the same thing. I want this macro to run every time I have the excel file open. however, when I run this macro, it locks me out from doing anything else with excel.
How do I get it so that I can be doing other stuff while its running that macro?
-
Dec 28th, 2007, 02:49 PM
#9
Re: Including a API in VBA(excel)
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 28th, 2007, 04:03 PM
#10
Thread Starter
Junior Member
Re: Including a API in VBA(excel)
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim i As Integer
Sub Module1()
For i = 0 To 100
Cells(67 + i, 2) = Range("O13").value
Cells(67 + i, 3) = Range("P13").value
Sleep 5000
Next
End Sub
O13 and P13 and numbers that are constantly changing, and i want to record the value of those cells every few seconds. When i run this though, they stop updating.
I bet it has something to do with the sleep function eh?
-
Dec 28th, 2007, 04:14 PM
#11
Re: Including a API in VBA(excel)
Yes, the Sleep API stops the processing on your thread while its sleeping.
If you need a delay in the loop then there are other ways to do it like the Timer function in Excel.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 28th, 2007, 04:18 PM
#12
Thread Starter
Junior Member
Re: Including a API in VBA(excel)
ah excellente, thank you very very much for everything!
-
Dec 29th, 2007, 04:00 PM
#13
Thread Starter
Junior Member
Re: Including a API in VBA(excel)
Is the timer function defined automatically, or do I have to create it?
-
Dec 29th, 2007, 04:35 PM
#14
Re: Including a API in VBA(excel)
From the Excel Help file.
Code:
Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|