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.
Related
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).
I am making a template and thought to store our logo.jpg inside a userform. Then I'll call this userform and insert the logo in the print header for each "macro activated" print.
So far I have managed to print the image only as numbers. Bits and bytes probably(?). I might be missing some conversion of the picture before printing:
FilePageSetupHeader Alignment:=pjLeft, Text:="&P" & UserForm1.Image1.Picture & " "
This prints as: 1-670746914 in the top left header.
What am I missing?
The syntax I found on MSDN gives the following parameters for inserting a picture:
&;P""path"" Inserts the specified image. An example would be &;P"" [My Documents] \Image.gif"". The term [My Documents] represents the full path to your My Documents folder.
My code makes a copy of the current view, make changes to the view settings, headers etc, before exporting to PDF and deleting the view again.
UserForm1.Image1.Picture is a picture object, not the path to the original source file. Once a picture is loaded into an image control, it is embedded and its original path is not stored.
Store the path the the picture so that you can reference it later (e.g. using the Tag property of the Image control). See Stack Overflow: VBA UserForm Get Filename for more details. (FYI: Excel and Project use the same UserForm object, so this is applicable.)
I gave up on saving the logo inside the Project file itself.
Instead I check if the logo exists inside "C:\CompanyLogo", if does not, create that direcotry and download it from imgur.
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.
Hi I'm new to using Crystal Report XI and I'm having a difficult time with this issue.
I run a billing statement using Crystal Report Monthly. And I process at least a thousand statements on one PDF. The header ie: "DB---Break" tells our system when a participant statement ends and a new statement begins (Mailing Purposes).
However, if a participant has an overflow of statements that goes onto the the next page. The header "DB--Break" cuts off that statement for that participant.
With all that being said, I'm currently trying to find a way to suppress the header on the second page of the participant who has a overflow of information. How would go about resolving this? Thanks in advance
Example:
DB----Break (Header)
Joe Smith, (Name)
TEXT TEXT TEXT (body)
--------Break in Page----------
DB--Break (Need to suppress this Header)
TEXT TEXT TEXT TEXT (continuation of body from John Smith)
--------Break in Page----
DB----Break (Header)
Sarah Johnson, ( New Participant Begins)
TEXT TEXT TEXT (Body)
Try this:
Right click on Header -> Select Section Expert.
Highlight the header you want to suppress. On the Common tab to the right check the supress checkbox
Then click on the formula x+2 button and enter the following formula:
pagenumber > 1 and click on Save and Close.
This should suppress the header section on second page.
I am making an "intelligent save" button for word and excel files.
The first time it is run from a file, it will prompt user to navigate to the correct folder. The important part is the selected path will be saved for that file and automatically referenced the next time someone uses the macro. Then the user can specify pdf vs. docx/xlsx file type, then save the file.
Is the bolded part possible, and what kind of technique/functions can I use to do this?
Posted as an answer, with a bit of example code and more detail:
For such a small amount of data, why not use VBA's SaveSetting/GetSetting commands to put the needed info in the registry?
Sub SaveGetSettingExample()
' Saves string values to:
' HKEY_CURRENT_USER\Software\VB and VBA Program Settings\AppName
SaveSetting "AppName", "Section", "Key", "Value"
' Displays the just-stored value: Value
MsgBox GetSetting("AppName", "Section", "Key", "Default Value")
End Sub
I'm assuming you're embedding the code in the workbook (and not in the Personal code folder). If so, I've had success writing the file path to a cell in a hidden column (usually out to far right of view) in Excel. Your code can reference this default location as needed when loading the next time.
I'm not sure about Word, our Word documents stay pretty simple.