-
WSgeofrichardson
AskWoody LoungerThanks, I missed that. Dohl.
-
WSgeofrichardson
AskWoody LoungerHello Jaggi
I used the following stripped down version of your code. Very simple.
I have hard coded a path for simplicity. Converted docs are saved to the same location.
If I have two word documents (word 2010) and one document is password protected the macro pauses and requests a password.If there is a pdf in the folder it seems to hang before failing.
Always disable resume next for debugging purposes.
Pay attention to the use of document vs documents and pay particular attention to the set commands in your code.G
Code:Sub jaggiTest() Dim fs As Object Dim oFolder As Object Dim tFolder As Object Dim oFile As File Dim strDocName As String Dim intPos As Integer Dim locFolder As String 'On Error Resume Next locFolder = "D:Datatestjaggi" 'Application.ScreenUpdating = False Set fs = CreateObject("Scripting.FileSystemObject") Set oFolder = fs.GetFolder(locFolder) For Each oFile In oFolder.Files Application.Documents.Open (oFile.Path) strDocName = ActiveDocument.Name intPos = InStrRev(strDocName, ".") strDocName = Left(strDocName, intPos - 1) ActiveDocument.ExportAsFixedFormat OutputFileName:=locFolder & strDocName, ExportFormat:=wdExportFormatPDF ActiveDocument.Close Next oFile 'Application.ScreenUpdating = True MsgBox ("Documents are successfully Converted!") End Sub
-
WSgeofrichardson
AskWoody LoungerHi Jaggi
Please comment out on error resume next.
Run the macro again to see the error dialog.
G -
WSgeofrichardson
AskWoody LoungerHi
I will admit to be confounded. I didn’t give you a hope in Hades of getting close.
It converts the document to PDF, but when I am trying to add the code to close the document.
Do you actually see a .pdf created in addition to the .dot(?)
If so all bets are off. What happens withdocuments.close saveChanges:=wdDoNotSaveChanges
See this link at msoft about the Close method
Cheers
G -
WSgeofrichardson
AskWoody LoungerHi Maud
Space Mid String
Thanks for the advice on substitute() v Trim().
I was thinking that it was necessary to preserve the space mid string in that Post Code.
I wondered how it might mess with the URL though.
G -
WSgeofrichardson
AskWoody LoungerHi
I thought there would have been a method to refresh the validation. I can’t find one.I started playing around trying to test if the current cell had validation applied and if not then apply some.
In this example the range h1:h5 had a list of colours.I would be interested to watch for others’ comments on this.
I wondered if an auto macro could be run on workbook_open that selected the last cell in the mileage column and checked for validation.
The little bit of following code is ugly but it works. I don’t like creating and then trapping for error conditions. Somebody might have a better idea.In this example I am looking for a validation type. These types have constants 0-7.
I created the validation code in the With Selection.validation … End with structure by recording the macro that resulted when I clicked the validation button.I added some more thoughts later in the day.
Code:Sub TestValidation() On Error GoTo errorHandler If ActiveCell.Validation.Type > -1 Then 'MsgBox (" has validation") Exit Sub End If errorHandler: Select Case Err.Number Case 1004 With Selection.Validation .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:="=$H$1:$H$5" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With Case Else 'add stuff here End Select End Sub
Additional thoughts.
I have attached a workbook with an auto workbook_open macro in the this workbook object.The code checks the first empty cell in the column for data validation and if necessary adds a validation rule. I also rejigged the error checking a bit for discussion.
Cheers
G -
WSgeofrichardson
AskWoody LoungerHi
I found this link and thought it might help you.I ran the code on Office 2010 and created a reminder OK. I commented out a line that references a nextbusinessday function. Read his page.
I cant guarantee anything.
I don’t know the author but he deserves credit for this.Cheers
G -
WSgeofrichardson
AskWoody LoungerHi
I think that the pivot views on tables and the ability to create pivot queries in Access might help.Then there is the ability to export to Excel and use the Pivot table functionality within Excel.
PowerPivot might be another really powerful tool for you to play with. This is the free Excel add-in. That lets you connect directly to the database and introduces an expanded range of functions as well as DAX (Data Analysis Expressions).
See more about DAX here.
Cheers
G -
WSgeofrichardson
AskWoody LoungerHi
The following line in you code means that the routine has to open the document. Password required !!
Code:Set d = Application.Documents.Open(oFile.Path)
Do all the documents have the same password? A forlorn hope.
I guess you dont have access to the hard copies. If you did then you could scan them to pdf.
Nice to know the security works !
You can include the password in the code that opens a document.
It is not recommended to hard code this in a routine however.see this linkat msoft.
Cheers
G
Geof -
WSgeofrichardson
AskWoody LoungerHi
Here is a simple example
Code:Sub makeURL() Dim sURL As String sURL = Range("a2") sURL = sURL & Range("a3") sURL = sURL & Range("a4") sURL = sURL & Range("a5") sURL = sURL & Range("a6") sURL = sURL & Range("a7") sURL = sURL & Range("a8") Range("a10").Value = sURL Range("a11").Select With ActiveSheet .Hyperlinks.Add anchor:=.Range("A11"), _ Address:=sURL End With End Sub
Screen shot of associated spreadsheet.
41495-makeURLObviously you need to work on a loop to drag in 60 cells and trim each up a bit.
Hope it helpsCheers
G -
WSgeofrichardson
AskWoody LoungerHi
The vba Trim() function might work for you in place of the substitute expression.
Put something in A1 that contains spaces fore and aft then run this.Code:Sub testTrim() Dim sNew As String sNew = Trim(Range("a1")) ActiveCell.Offset(1, 0).Select ActiveCell.Value = sNew End Sub
G
-
WSgeofrichardson
AskWoody LoungerHi
I have office 2010 and they are in
C:Program FilesMicrosoft OfficeOffice141033QuickStylesJust a guess try C:Program FilesMicrosoft OfficeOffice151033QuickStyles.
Cheers
G -
WSgeofrichardson
AskWoody LoungerJuly 28, 2015 at 12:27 pm in reply to: Populate Cells Based on Matched Criteria and Enter Value From Another Cell #1517467Hi sbdale
Welcome to the world of date arithmetic.
You need to understand that excel treats dates as serial numbers. (Capt Kirk says star date 42214)
We mere mortals need dates formatted to show years, months and days.See this postfrom the office support folks at microsoft.
Enter a date in a cell and experiment with the formatting (Ctrl + 1).
Experiment with the datedif() function as well. See this linkfor info.
Cheers
G -
WSgeofrichardson
AskWoody LoungerHi
You could try the F5 key.
Select the option for visible cells.Make sure you have the data selected first though.
Without knowing your exact intentions I would suggest that you read up on pivot tables.
G
-
WSgeofrichardson
AskWoody LoungerJuly 28, 2015 at 12:19 am in reply to: Populate Cells Based on Matched Criteria and Enter Value From Another Cell #1517373Hi
or this=C2-DATE(YEAR(C2),1,1)+1
Then there is =DatedIf function.
=DatedIf(date1, date2, intervalType)Cheers
G
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
2 hours, 26 minutes ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
3 hours, 33 minutes ago -
0Patch, where to begin
by
cassel23
3 hours, 18 minutes ago -
CFPB Quietly Kills Rule to Shield Americans From Data Brokers
by
Alex5723
17 hours, 10 minutes ago -
89 million Steam account details just got leaked,
by
Alex5723
4 hours, 56 minutes ago -
KB5058405: Linux – Windows dual boot SBAT bug, resolved with May 2025 update
by
Alex5723
1 day, 1 hour ago -
A Validation (were one needed) of Prudent Patching
by
Nibbled To Death By Ducks
16 hours, 42 minutes ago -
Master Patch Listing for May 13, 2025
by
Susan Bradley
3 hours, 50 minutes ago -
Installer program can’t read my registry
by
Peobody
4 hours, 43 minutes ago -
How to keep Outlook (new) in off position for Windows 11
by
EspressoWillie
14 hours, 29 minutes ago -
Intel : CVE-2024-45332, CVE-2024-43420, CVE-2025-20623
by
Alex5723
21 hours, 50 minutes ago -
False error message from eMClient
by
WSSebastian42
1 day, 12 hours ago -
Awoke to a rebooted Mac (crashed?)
by
rebop2020
1 day, 21 hours ago -
Office 2021 Perpetual for Mac
by
rebop2020
1 day, 23 hours ago -
AutoSave is for Microsoft, not for you
by
Will Fastie
19 hours, 45 minutes ago -
Difface : Reconstruction of 3D Human Facial Images from DNA Sequence
by
Alex5723
2 days, 2 hours ago -
Seven things we learned from WhatsApp vs. NSO Group spyware lawsuit
by
Alex5723
1 day, 3 hours ago -
Outdated Laptop
by
jdamkeene
2 days, 8 hours ago -
Updating Keepass2Android
by
CBFPD-Chief115
2 days, 13 hours ago -
Another big Microsoft layoff
by
Charlie
2 days, 13 hours ago -
PowerShell to detect NPU – Testers Needed
by
RetiredGeek
10 hours, 33 minutes ago -
May 2025 updates are out
by
Susan Bradley
1 hour, 29 minutes ago -
Windows 11 Insider Preview build 26200.5600 released to DEV
by
joep517
2 days, 19 hours ago -
Windows 11 Insider Preview build 26120.3964 (24H2) released to BETA
by
joep517
2 days, 19 hours ago -
Drivers suggested via Windows Update
by
Tex265
2 days, 19 hours ago -
Thunderbird release notes for 128 esr have disappeared
by
EricB
15 hours, 9 minutes ago -
CISA mutes own website, shifts routine cyber alerts to X, RSS, email
by
Nibbled To Death By Ducks
3 days, 2 hours ago -
Apple releases 18.5
by
Susan Bradley
2 days, 20 hours ago -
Fedora Linux 40 will go end of life for updates and support on 2025-05-13.
by
Alex5723
3 days, 3 hours ago -
How a new type of AI is helping police skirt facial recognition bans
by
Alex5723
3 days, 4 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.