Add page number to hyperlinks in a Word document - google-docs

I have a large number of documents created using Google Docs which contain hyperlinks to section headings. This works fine when viewed online, or exported to Word/PDF and viewed electronically, but they're obviously useless in print. What's the best way to get a page number (preferably) or section number (would do in a pinch) into the displayed text of the hyperlinks? Thanks for any help!

I managed to find a workable, though not particularly elegant, solution. It does not automatically update, so you only run it once before printing. Putting here in case it helps other people like me :)
Sub AddPageNumberToHyperlink()
For Each link In ActiveDocument.Hyperlinks
' Find target heading and get its text
link.Follow
' Get current pagenumber (since we just followed the link) and add to display text
link.TextToDisplay = link.TextToDisplay + " on page " + Str(Selection.Range.Information(wdActiveEndPageNumber))
Next
End Sub

Related

CodeModle.Insertlines drops variables

After several days of searching Excel vba forums I have finally given in and must now ask for help.
The problem is that CodeModle.Insertlines causes excel to drop all variables. I have a couple arrays that I need to use / check boxes and list boxes etc. all get wiped when I run the code below
With Application.Workbooks(ActiveWorkbook.Name).VBProject.VBComponents("UserSavedQueries").CodeModule
.InsertLines 2, "tmp = " & """" & "THIS IS SOME SAMPLE TEXT " & """"
End With
I fully admit that the Insertlines was a bit of a work around as a way to an end, but that way now seems blocked. Please can someone advise how to insert lines into a module without resetting all variable?
For the bigger picture (and for someone to advise how I probably should have tackled this in the first place)
I have a sheet that pulls together a bunch of parameters from list boxes, checkboxes cells etc when a user selects the ‘Go’ button.
the selections are formatted to make a JSON message that is sent to an API and the response is displayed in a table on a second sheet.
To give some context, Imagine Listbox1 called “search criteria” with selections of “Manufacturer, Colours, Countries”. Listbox2 called “Filters” changes context depending on the selection on Listbox1. So we could have for Listbox2: “Ford, BMW, Nissan” , “Red, Blue, Green, Black, White”, “ ”. Not the actual data but it shows the varying length of each selection. There are actually around 12 available selections some of which have 100+ filter options.
The user may select “Ford, Red” which would return red Fords in all countries or “Ford,BMW,Green,Scotland” which would just Green Fords and BMWs in Scotland.
All of this works nicely.
NOW: I need to add the ability to have “Saved User Selections”. I need to avoid dumping these selections in a worksheet (even hidden) as it allows the user to “fiddle” with the shape and format of the selection which will break the JSON parsing. So I decided to save the user selections in a VB module. A UserForm provides the ability to Name the saved selection, date-stamp it and runs the code above. Parsing the UserSavedQueries module returns a listbox of all saved selections, which, when double-clicked are intended to populate listbox1 & 2 ready for the user to hit ‘Go’.
Considered options: I haven’t ruled out saving to an external file, or maybe even registry, but would prefer to keep self-contained within the one file.
This article came closest to helping, but I'm not sure how it would work for my use-case

How do I take the title of a website and add it to an Excel spreadsheet using AppleScript + Excel

I'm pretty sure this is an easy task, but I can't seem to find what I'm looking for.
In short, I would like to use a keyboard shortcut take the title of the current page I'm on, and save it to an Excel document, basically creating a log of websites. If possible, I would like to add a link to the title that is saved in Excel.
I know how to add the Applescript as a service or workflow and such, but I can't wrap my mind around how to code this. The farthest I've gotten is grabbing the name of the website, but have no clue how to paste it to Excel, add a link to the title, then go to the next line.
Thank you for any assistance you may have.
Try these two lines of AppleScript
tell first document of application "Safari" to set pageTitle to name
tell first document of application "Safari" to set pageURL to URL

Drive spreadsheet, wrapping link

I'm trying to find a way to make Google Spreadsheet wrap a link, and showing the content in many lines, just like microsoft excel works:
I've found nothing so far on how to implement this, which should be used very often I believe.
Here's how the same excel works imported to Google Spreadsheet:
In the google spreadsheet I selected "Wrap text" but it only wraps it, hiding the overflow of it, however I can't see the whole link.
Any help is greately appreciated.
If you don't mind modifying the contents of the cell in order to display wrapped text, you could use an additional column with a formula like this to insert spaces after certain characters so that the url can wrap:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1,"&","& "),"/","/ "),"?","? "),"#","# ")
You should keep the original URL around though, since the resulting value will no longer be a valid URL.
Google Spreadsheets only wraps text where there is white space or hyphens. It will not wrap in the middle of a word the way Excel does. There's no way around this I'm afraid.

Adding a title after spreadsheet and macros are written

I have been making a spreadsheet with sorting macros for my work for about the past week. I finally finished up the coding(98% of it) and my boss now tells me I need a title at the top of the spreadsheet when it prints. All of the codes I have written error when I shift the data down in order to add a title in row 1. Is there a way to add a title without having this happen? I'm a novice with VBA all around and recieved a decent amount of help with this project so bear with my ignorance please! Thanks in advance.
You can use the Page Header settings to add a title, without affecting the rows themselves.
If you have a worksheet object called sheet, you can set its header in code using the PageSetup property:
sheet.PageSetup.CenterHeader = "Centered Title"
You can also control the left & right headers and center/left/right footers like this.
There is no need for VBA. Simply add a header to your document. Go to Insert, Header and Footer.

form view in excel for a record

I have a sheet in excel that is basically like a database (yes it has to be in excel unfortunately) and I want to design a simple form to display the records (the different column values in the rows). Usually MS is good with making widgets to do this but I cant seem to figure out how to write it in VBA (easily)
Basically I have a list of Names and ID#'s then some other columns that need to be filled in (address, order # etc) but I'd like the user to do this via a form rather than typing in excel. I created a small form in VBA, but now I cant link the columns to the textboxes in the form.
Anyone know of any code I can plug and play to do this.
Specifically I am using a ComboBox (for the list of names) and then a for loop searching through it to find the selection and updating data. But its a real pain.
plus I cant figure out how to put in a 'Next' button, which is really annoying me. Does anyone know how to change the comboBox value to the next row, if it is linked via RowSource
Have you considered the Form feature? You can find under the commands you can add to your QuickAccess toolbar.
Check this helpful tutorial for additional details.

Resources