Error when using GetCommandLineA

T

TRO

Running the following code (within EXCEL 2000) I get a
Application Error.
Code:

Public Declare Function GetCommandLineA Lib "Kernel32" ()
As String

Sub probe()
Dim s As String
s = GetCommandLineA
MsgBox s
End Sub

Error:
The instruction at "0x77e87af2" referenced memory
at "0x00190000". The memory could not be "read".

The strange thing is that using this code within Word 2000
it works perfectly well. And to carry this to extremes, I
have a Excel file containing such code which works. But if
I save this program via Excel under a new name, the copy
produces the same error as described above.
 
C

Chip Pearson

Initialize the string first.

Dim s As String
s = String(255, " ")
s = GetCommandLineA
MsgBox s


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
G

Guest

Thanks again, but unfortunately it does not work.
-----Original Message-----
Initialize the string first.

Dim s As String
s = String(255, " ")
s = GetCommandLineA
MsgBox s


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top