سؤال

Can someone tell me what is going on with the code below:

'Variables at top of module or some function/sub here

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

 'some function or sub routine here

This code shows the position of the function declare. I am not familiar with what the declare keyword is doing, nor do i understand why this is not compiling.

I got this when I was looking up ways to open tabs in internet explorer through vba, but I can't seem to get it to work.

It seems as though the compiler does not recognize this as a function, but I have seen several forum posts that use this code without it having any problems (this one included).

It seems as though I may be missing a reference, or possibly the dll, but i don't see the library as a reference in the tools menu, and i don't know how to check if i have this on my machine.

If someone could point me in the right direction that would be great.

هل كانت مفيدة؟

المحلول

An API declaration is like a regular variable declaration: it must be at the top of the module, before any Subs/Functions.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top