This question already has an answer here:
Replace text on header and footer of Excel file
(1 answer)
Closed 5 years ago.
Is there a way to access Excel's built-in custom footer dialog box with VBA? I'd like to access the actual dialog box; I know how to directly modify the footer via ActiveSheet.PageSetup.
I can open the Page Setup box via Application.Dialogs(xlDialogPageSetup).Show but I'm not able to get to the Header/Footer tab, then Custom Footer.
Here's what I've tried:
Application.Dialogs(xlDialogPageSetup).Show
Application.SendKeys "h" 'Go to the Header/Footer tab
Application.SendKeys "{TAB}{TAB}{TAB}{ENTER}", True 'Go to Custom Footer
Thank you.
EDIT:
Thanks for your responses thus far, and my apologies for not being clearer.
As noted above, I understand how to use ActiveSheet.PageSetupto modify the Left/Center/Right footer fields; however, I'd like to directly access the Custom Footer dialog box so that non-technical colleagues can easily modify these fields, in a familiar manner, as opposed to having them look through the VBA and changing the existing text strings and/or codes.
You don't have to call any dialogbox. You can access header/footer directly:
ActiveSheet.PageSetup.CenterHeader = "&D &B&ITime:&I&B&T"
More at MSDN - Formatting and VBA Codes for Headers and Footers
To be more precise it would be
ActiveSheet.PageSetup.CenterFooter = "&D &B&ITime:&I&B&T"
for the footer.
There are three points you can access, LeftFooter, CenterFooter, and RightFooter. It will be the same for the header.
This question has already been asked and answered here.
Related
I am trying to write a VBA macro that runs when opening a .docx document. I want it to force the display of the Navigation Pane and then force all of the headings (any level) to display in collapsed mode. I am trying to get the code for the Collapse command using the macro recorder.
All I have when I record the macro is:
ActiveWindow.DocumentMap = True
Right-clicking on a heading in the Navigation Pane and collapsing does not record a code line. Is there a VBA method for this event?
I "solved" this requirement for myself by means of an AutoHotKey script, which just sends the necessary mouse click and subsequent key strokes. Not beautiful, but it works most of the times.
Kind regards, Hauke
As of this writing in 2019, this is not possible through VBA. It's been asked for from Microsoft for a long time.
As originally suggested in this Microsoft forum post, the quickest way to collapse all of the headings in the Navigation pane is to right-click one of the headings and click Collapse All. Obviously this is not an automated/macro-based solution, but it's all we have until Microsoft exposes the task panes through the VBA object model.
We are using SQL Server Reporting Server 2014. On exporting report into excel we are getting error "Length cannot be 0. Missing parameter Length". After research, we found that excel doesn't allow more than 255 characters in footer. We would like to hide footer on excel import only.
Is there a global settings on report level which we can apply to hide page footer in excel import. From google search, it is clear that we can add global logic to each text box within page footer to hide it. However, we didn't find any global report level logic to hide page footer in excel import. Can someone help us and provide logic to hide page footer on report level?
Thanks.
=(Globals!RenderFormat.IsInteractive = "EXCEL")
Use =Globals!RenderFormat.Name = "EXCEL".
The .IsInteractive you used returns a boolean and tells whether the report is being run interactive. The .Name returns the format name.
I placed all my textboxes inside a rectangle and turn on/off the visibility based on the answer above. This is so you don't have to do it on each textbox.
I'm sure this question has an easy answer, but I have a short timeline and need to get it resolved ASAP.
I'd like to have a content control drop down that when the user makes a selection, will update a legacy text box formField with the selected value.
I have no trouble selecting form fields and setting them using VBA code:
ActiveDocument.FormFields("MyFieldName").Result
But I'm having trouble selecting the value from the content control, and also figuring out how to execute the macro "onExit" like I can with legacy fields / drop downs.
Any suggestions?
Google "vba content control events".
For example, see the last post by Greg Maxey at how-to-catch-custom-control-events-with-vba-macro and towards the bottom of his page http://gregmaxey.mvps.org/word_tip_pages/content_controls.html
Friends,
I'm using VBA to create Lotus emails populated from an Excel spreadsheet, and I'm stuck on a really silly point.
When I create a new section in the note, business rules require me to give it a border. They've been doing this manually for years and are used to doing this from the Notes UI. They create a new section, then go to its properties and then change it to have a border (please see the border and style part in the properties window in this screenshot).
I can't figure out how to add this border through VBA. Any ideas? I've tried changing the TitleStyle, but that only affects things like fonts and color. I have everything else done, just stuck on the border!
Thanks!
Mike
The NotesRichTextSection class doesn't give you any way to change the border, unfortunately. Rich text items in Lotus Notes aren't supported very well via the API, so often you'll find a mismatch between what you can do on the client vs. what you can do in code.
There might be a workaround if you're up for trying it. First you need to create a simple form in Notes that has a rich text field, let's call it Body, surrounded by a section. Setup the section to appear however you want, with the border set, etc. You'll also need another hidden text field, called Title, and you'll set the section's title to be computed based on that Title field.
Then in your VBA code you're going to create a new NotesDocument based on that form. You'll set the Title field, and you'll add content into the Body rich-text item. Then you'll need to call the ComputeWithForm method followed by the Save method. Finally, you can use the RenderToRTItem method on the document to put the entire document into your original note's rich text field. Make sense?
No guarantees that will work from VBA, but I've done similar things in the past using LotusScript and it did the trick.
You could just set the borders of the cells you are copying using the Borders() property.
Example:
Range("B2:C4").Borders.LineStyle = xlDash
Range("B2:C4").Borders(xlEdgeBottom) = RGB(255,0,0)
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Can the new WP7 cut and paste functionality be used programatically?
Is there a way to programmatically copy/paste text in windows phone. I want the user to click on a button that should automatically copy some text to the clipboard. The text resides on a TextBlock control (which may be hidden). The only workaround that I have thought of is to pop a dialog with the text filled in in a TextBlock (which natively supports copy paste).
Thoughts?
To set text : Clipboard.SetText("foo-bar")
To check if clipboard contains text : Clipboard.ContainsText("foo-bar")
No method to to get text Clipboard.GetText() results in Security Exception