Access 2007 VBA - Is There a Variable that Indicates if a Report Was Printed? - vba

I am using Access 2007 and it contains a report that I usually run with this VBA code:
DoCmd.OpenReport "rptSales", acViewPreview
I click the "Close Print Preview" button on the ribbon if I don't need to print the report.
But once in a while I want to print the report, so I click the Print button on the ribbon,
which launches the Print Dialog box, and I click OK to print.
Here's my question - is there a way to know if a report was printed? For example, is there
a variable I can refer to after the report closes (like acReportPrinted) that tells me if the report was printed and not just previewed?
I want to keep track of how many copies were printed.
Thank you.

Related

How do I make a userform appear on demand in Microsoft Word?

I can make it popup on opening the document, but what if I close the userform and want to it to show up again in the same document? I know in excel you can add a button onto a worksheet directly and make it show the userform on click, but this button is unavailable for microsoft Word. Is there a solution besides initiating the script by hand?
To display a VBA userform, you can trigger it from a macrobutton field, from a form field, from a shape, from a QAT button or from an ActiveX button. There are probably a couple of other methods I'm not remembering at the moment. Each is a little different in the exact steps, but all will run the command:
UserFormName.Show

Copying report fields in ms access report vba

I want to create button that copies fields in a report which comes from a form but I cant figure how to write the VBA behind button in VBA . I am sure its pretty simple but cant figure it out. I appreciate if you can help me.
To convert an Access 2007 form to a report, follow these steps:
Open the database containing the form.
Click the name of the form in the Navigation pane.
Click the Microsoft Office button.
Point to Save As and then click Save Object As.
Click in the Save "Form_Name" To text box and enter a name for your report.
Click the drop-down arrow in the As text box and select Report from the list, then click OK.
No VBA required.

Copying text from popup window

My employer uses SAP to generate purchase order numbers. The PO number is displayed in a popup window. I need to use a VBA script to copy the PO number (or the whole text) so that it can be pasted into Excel.
I have tried using the script recording tool to get the command (it doesn't record the mouse clicks to select and copy, nor the keyboard commands), and it won't let me print to One Note or Microsoft XPS Document Writer.
Any suggestions would be greatly appreciated. Image of the popup window is here:
The message is displayed in the status bar at the lower end of the screen.
with VBA you can read this as follows:
STATUS_BAR_TEXT = session.findById("wnd[0]/sbar").Text

Display Excel App as first window on the screen when there is a pop up box from a running macro

I am running an excel macro from a script, I just double click on the .vbs file and it does all the work properly.
The only issue i am facing is, i have some input and messages boxes in the macro and as i am running it from the .vbs file so i don't see the excel file and if i have other windows opened like google chrome or file explorer so i have to click everytime on excel application in the taskbar to see the input box or the message box.
I should have the screen clear so that when the script is running and i have an input box it will pop up as first window.
Is there a way how to pop up this input box or message box as first window even when i have other windows opened ?
Thank you for suggestions.
You can activate the Excel application before displaying the message. In your VBA macro code,
AppActivate Application.ActiveWindow.Caption
str = InputBox("Please enter a string")
MsgBox "you entered: " & str
' etc ...

How can I programmatically bring up the document properties window in Word and go to the Summary tab?

I am developing a VB6 COM add-in for Microsoft Word and I have added a button to the Ribbon which will save the document to a database. But before the document is saved, I want to take the user to the document properties window so they can fill in the properties for the document (like Title, Subject and Author). I am using the following statement to bring up the window:
Application.Dialogs(750).Display
This works fine, but it defaults to showing them the General tab. The fields for Title, Subject and Author) are on the Summary tab. Is there any way to bring up this dialog box and force it over to the Summary tab? I thought about sending keystrokes, but the tabs don't have hotkeys associated with them.
I need this to work in Word 2007 and Word 2010. The line above already works fine in Word 2003 because 2003 doesn't have a multi-tabbed properties window.
You can bring up a seperate box for this (works in both Word 2000, 2003, 2007 and 2010):
Application.Dialogs(wdDialogFileSummaryInfo).Display
or
Application.Dialogs(86).Display
You can also program against this dialog. See here for an example.
You could record a macro then execute it as needed.
Changing .Display to .Show works, except you get an error if you press ESC, so you have to wrap it in On Error Resume Next (no idea why).
Sub CustomProperties()
On Error Resume Next
Application.Dialogs(750).Show
End Sub