Where do I insert this code to create the macro in CorelDraw X7? - vba

I'm referring to this post here:CorelDraw X6 Macro to insert Date using DTPicker Control
I am creating a template for everyday use for saving artwork proofs to send onto customers for visual approval. I'd like the following boxes to auto populate the following information:
1. A box that will populate today's date
2. A box that will populate the work order number based on the first 6 digits of the filename
3. A box that will populate the filename as a whole
The rectangles/boxes will already be in the document that gets imported. I just want to create a macro, or multiple...to click in order to fill these boxes before exporting to a PDF for customers approval.
I'm a total coding n00b and can't find specific directions on where to copy the code listed in the link above.

In the Corel Draw menu, go to "Tools" then "Macros" then "Macro editor".
After that, you can paste it in the right hand side of the screen, on the white empty box.
That should do it.

Related

vba word 2016 saveas document without changing module name

I suspect my strategy is incorrect as I can't seem to apply my search results for the keywords I've used over the last few days. ( https://stackoverflow.com/questions/54496552] seems to be the closest. )
I am able to populate a single document from the two forms I've built and save it under a new name
...
MsgBox "Saving as " & aFullPath
ActiveDocument.SaveAs FileName:=aFullPath, FileFormat:=wdFormatDocumentDefault
But that changes the name of my parent document that contains my forms (Word2016 document name: waiver.docm). In practice, that won't be a problem because the user will not be saving "waiver.docm" except by accident.
But that's why I think my approach is wrong.
Ideally my VBA code would
Load a protoype waiver template with the page heading, bookmarks and table as I have now in my waiver.docm.
Upon filling that template, append another waiver template as a new page.
And return control to the form
Repeat above two steps of appending of sheets until the user indicates completion (e.g. "Finish" command button). Typically after 1 to 4 pages
Print and save the entire document.
Right now I interrupt the process after each page to force my prospective user to print and save the document (and under a unique name).

How to pull text from a shape in a Word document using VBA?

I'm trying to grab the text from inside a shape on a Word document.
Sub textgrab()
MsgBox ActiveDocument.Shapes("Rectangle 85").TextFrame.TextRange.Text
End Sub
I get the error:
Run-time error '-2147024809 (80070057)':
The item with the specified name wasn't found.
In the Word document when I go to the top menu, hit the shape format tab, and in the arrange section, I select 'selection pane', I get a list of all the shapes, 'Rectangle 85' is there.
When I select it, it highlights the box i'm trying to grab the value from.
This is a pdf that I've opened in Word. I'm trying to automate a process that will open a pdf invoice, grab the dollar total, and pull it into Excel.
Solution for those that stumble upon this later. I used the following:
ActiveDocument.ActiveWindow.Panes(1).Pages(1).Rectangles.Item(i).Range
Word can only extract text from Drawing objects. These are inserted in the UI, for example, from Insert/Shapes. Shape.TextFrame.TextRange has no OCR capabilities, so can't be used to get text "embedded" in other kinds of graphic objects, such as an embedded PDF file or a JPG or anything similar.
When uncertain whether a particular Shape supports reading or writing text, right-click it in the UI and see if the menu selection Add Text or Edit Text is available.

Clicking Field with AutoIt in an ERP program

Here is my scenario:
I am starting AutoIT recorder. I record using the keyboard since using the mouse causes the script to stop most of the time or does something inaccurate when started after that.
What I do is I open up an Excel template I have created. I then go into an ERP system and copy a few columns which I paste into Excel. After these columns are inserted, a few more columns are calculated from the formulas I have previously inserted.
The problem is that when I am into the ERP system I have selected a specific time period...Let's say 1st November till 31st November. I then save the excel and use the Excel option to send an email to specific people with the excel report attached.
I compile the autoit script to an exe and I have a scheduler which starts the exe. The problem is that I need a way to change the date to December, then January and so on... How do I do that using AutoIt? Can it be done at all?
This is how the date looks like in the ERP program:
You need to first inspect the program using AutoIt Window Info tool: drag the target icon to the filed you wish to click on - use ControlClick. Let's take an example with Excel, it says the title is: "Book1 - Excel" and the ID of the button I chose is "1001", the script will be:
ControlClick("Book1 - Excel", "", 1001)
If there isn't any ID, it will be harder as you'll need to MouseClick by coordinates which is prone for errors...
Changing the time: in order to change the date picking according to the current month you'll need something like:
Local $stringInCell = ControlGetText("ERP title", "text in ERP window (can be empty)", controlID)
If #MON = StringLeft($stringInCell, 2) Then
ControlClick("ERP title", "text in ERP window (can be empty)", controlID)
EndIf
Where #MON is a macro, and StringLeft is like starts with, assuming the first 2 characters are good for you (e.g. January is 01).

In batch file, how to get focus on a specific window (opened file)

A very simple question I suppose, but I reached a deadlock with this:
I have to use a .bat file to imput plain text data into the right cells an excel sheet with lots of graphics content, vba parts, macro that deactivate "normal" EXCEL buttons and functions, password to protect the pre-typed functions, sudden and unexpected changes in the version of the "taget file", and many other complications...
My need is to be absolutely sure that the .bat is sending the sequence into the right version of the .xlsm file.
To do that I want to store the last known filename (that include the file version) in the .bat file, and I want to take focus on the excel window in wich the data have to be written ONLY IF the title of the excel window is exactly the same.
So Here is the question: How to get the focus on a specific open file from a .bat file?
You can't. If you wanted to use vbscript or jscript you could do what you want in a command prompt in an unreliable way (but it will work most circumstances).
Excel has it's own forms.
Put column headers in a row. Put selection in same row. Alt + D, O.
Plus you can make Excel only allow entries on some cells, like a invoice form.
Right click cell, Properties, Protection, Unlock. Then Alt + T, P, P.
Word has it's own forms similar to Excel (Word is also a spreadsheet).
Excel VBA language (and VBScript too) has input box command.
Sub main()
Sheet1.Range("A1").Value2 = InputBox("enter Value")
End Sub

What kind of variable is "&[Page]" in VB?

Today I discovered the expression "&[Page]" in some old VB code. It seems to hold a pagenumber in case some document would get printed. I (VB novice!) didn't know this existed but it did help me out seriously today! So I wonder whether there are more such "hidden" variables. Where can I find an overview?
I thought this is an "environment variable" or a "system variable" but Googling these seems to suggest that "&[Page]" belongs to neither category.
These are Header and Footer elements.
From the Header and footer tools (image from excel 2010):
Click this button to:
Page Number: Insert the &[Page] code that puts in the current page number.
Number of Pages: Insert the &[Pages] code that puts in the total number of pages.
Current Date: Insert the &[Date] code that puts in the current date.
Current Time: Insert the &[Time] code that puts in the current time.
File Path: Insert the &[Path]&[File] codes that put in the directory path along with the name of the workbook file.
File Name: Insert the &[File] code that puts in the name of the workbook file.
Sheet Name: Insert the &[Tab] code that puts in the name of the worksheet as shown on the sheet tab.
Picture: Insert the &[Picture] code that inserts the image that you select from the Insert Picture dialog box that shows the contents of the my Pictures folder on your computer by default.
Format Picture: Apply the formatting that you choose from the Format Picture dialog box to the &[Picture] code that you enter with the Insert Picture button without adding any code of its own.