This line of code opens NotePad - Shell "notepad.exe", vbNormalFocus - is there a way to…
- User
This line of code opens NotePad - Shell "notepad.exe", vbNormalFocus - is there a way to set the window size of NotePad when it opens
- Assistant
Yes, you can set the window size of Notepad when it opens using the Shell function by manipulating the command line arguments passed to Notepad. Here's an example code snippet:
vbShell "notepad.exe /A 10 10 800 600", vbNormalFocusIn this code,
/Ais an argument for Notepad that sets the window position and size. The values10 10 800 600represent the left, top, width, and height of the window in pixels, respectively. Adjust these values as per your desired window size.Note: Keep in mind that Notepad itself doesn't allow resizing its window, so you can only set the initial size when it opens.
- User
I am getting an error with this ammendment
- Assistant
Apologies for the confusion. My previous response contained an error. The command line argument "/A" do not represent the window position and size in Notepad. Unfortunately, it is not possible to set the window size of Notepad using the Shell function alone.
Notepad does not provide an option to control its window size programmatically. The window size of Notepad may be controlled using other programming languages or frameworks that allow more fine-grained control over the window, but not by using the Shell function alone.
If you require more control over the window size, you may consider using other text editors or creating a custom application using a different programming language or framework that provides better control over the window size and appearance.
- User
Th VBA event below works as expected. Is there a way of first opening a form that has a start date and an end date so that the search results are only between the dates. If it is possible , can you please show me how to do it.
Sub HistoryToNotepad() Dim sourceWorkbook As Workbook Dim destinationWorkbook As Workbook Dim sourceWorksheet As Worksheet Dim destinationWorksheet As Worksheet Dim path As String, fileName As String Dim lastRow As Long Dim i As Long path = "G:\Shared drives\Swan School Site Premises\PREMISES MANAGEMENT\SERVICE PROVIDERS" fileName = "Service Providers History.xlsx" Set sourceWorkbook = ThisWorkbook Set destinationWorkbook = Workbooks.Open(path & fileName) destinationWorkbook.Windows(1).WindowState = xlMinimized Dim activeSheetName As String activeSheetName = sourceWorkbook.ActiveSheet.Name Set sourceWorksheet = sourceWorkbook.ActiveSheet Set destinationWorksheet = destinationWorkbook.Sheets(activeSheetName) lastRow = destinationWorksheet.Cells(destinationWorksheet.Rows.Count, "J").End(xlUp).Row Shell "notepad.exe", vbNormalFocus Application.Wait Now + TimeValue("00:00:01") For i = 5 To lastRow Dim text As String text = destinationWorksheet.Range("I" & i).Value & " " & destinationWorksheet.Range("L" & i).Value SendKeys text SendKeys vbCrLf Next i SendKeys "^{HOME}" destinationWorkbook.Close False Set destinationWorksheet = Nothing Set destinationWorkbook = Nothing Set sourceWorksheet = Nothing Set sourceWorkbook = Nothing End Sub
- Assistant
To achieve opening a form with start and end dates before executing the search, you can use a UserForm in VBA. Here's an example of how you can modify your code to include the UserForm for date selection:
- User
Can you please show me how to creat this form and how to run it
- Assistant