Set Window Size using API SendMessage

  api, excel, vba, windows

I found code to open a PDF document using VBA for Excel. The procedure OpenPDF is called with OpenPDF "FullFileName", 3, 143 where ‘3’ is the page number to be displayed. "143" is received by OpenPDF as argument strZoomValue As String and then passed to an API.

Public Const WM_SETTEXT = &HC
Public Const VK_RETURN = &HD
Public Const WM_KEYDOWN = &H100

SendMessage lSecondChildFirstWindow, WM_SETTEXT, 0&, ByVal strZoomValue
PostMessage lSecondChildFirstWindow, WM_KEYDOWN, VK_RETURN, 0

I believe "143" causes the window to be maximized which don’t want. The window should be tiled. I wonder if I could just change the ‘ZoomValue’ to achieve that but to construct the lParam argument appears to be a rather complex science, different for each value of wParam. So, I wonder if someone might just tell me what I need. While at it, what’s the "ByVal" doing in the API call? Could that be replaced with "(strZoomValue)"? And why that? lParam is of Any data type. Why can’t the number be assigns as a Variant or even as Long or, at least, as String without further precautions?

BTW, I removed the two above lines from the code and got a maximized window. Therefore I presume that Windows remembers the size last used for Acrobat Reader, which was maximized by the "143" call. Therefore just ignoring the problem isn’t a plausible option.

Source: Windows Questions