Variable not defined compile error

P

Phil Hageman

I'm getting a compile error: Variable not defined, in Auto_Open.
DisplayVideoResolution is highlighted. What is the correction?

Sub Auto_Open()
Dim strResolution As String
strResolution = DisplayVideoResolution
If strResolution = "1024 x 768" Then
zoom1 = 78
zoom2 = 80
zoom3 = 81
pagezoom1 = 83
pagezoom2 = 87
pagezoom3 = 89
End If
RunSub1
End Sub
 
B

Bob Phillips

You need a bit more code

Declare Function GetSystemMetrics32 Lib "user32" Alias "GetSystemMetrics" _
(ByVal nIndex As Long) As Long
Dim zoom1, zoom2, zoom3, pagezoom1, pagezoom2, pagezoom3

Function DisplayVideoResolution() As String
DisplayVideoResolution = GetSystemMetrics32(0) & " x " &
GetSystemMetrics32(1)
End Function


Sub Auto_Open()
Dim strResolution As String
strResolution = DisplayVideoResolution
If strResolution = "1024 x 768" Then
zoom1 = 78
zoom2 = 80
zoom3 = 81
pagezoom1 = 83
pagezoom2 = 87
pagezoom3 = 89
End If
RunSub1
End Sub


Sub RunSub1()

End Sub
 
P

Phil Hageman

Hi Bob,

Thanks for your reply. I pasted the code in and got a compile error: Syntax
error. The line DisplayVideoResolution = GetSystemMetrics32(0) & " x " & is
highligted. When a click OK on the message box, the line Function
DisplayVideoResolution() As String highlights yellow, and the Display....
line becomes red font. Where did I go wrong?

Thanks, Phil
 
B

Bob Phillips

Hi Phil,

Good old wrap-around problem

Declare Function GetSystemMetrics32 Lib "user32" Alias "GetSystemMetrics" _
(ByVal nIndex As Long) As Long
Dim zoom1, zoom2, zoom3, pagezoom1, pagezoom2, pagezoom3

Function DisplayVideoResolution() As String
DisplayVideoResolution = GetSystemMetrics32(0) & " x " & _
GetSystemMetrics32(1)
End Function


Sub Auto_Open()
Dim strResolution As String
strResolution = DisplayVideoResolution
If strResolution = "1024 x 768" Then
zoom1 = 78
zoom2 = 80
zoom3 = 81
pagezoom1 = 83
pagezoom2 = 87
pagezoom3 = 89
End If
RunSub1
End Sub
 

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