Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-15-2014, 10:58 PM
smndnm smndnm is offline refering to the msoFileDialogueOpen variants Windows 7 64bit refering to the msoFileDialogueOpen variants Office 2010 64bit
Novice
refering to the msoFileDialogueOpen variants
 
Join Date: Jul 2014
Location: Queensland
Posts: 24
smndnm is on a distinguished road
Default

I don't want to open the PDFs, I need to batch process them to apply security settings, it is an attempt to open an instance of Adobe pro locally if not already open.

I am so close, I can taste it...


There are only two issues with the code below and it is still valid inside this thread.

issue1 = It throws an exception at the"msoFileDialogFilePicker" stage when the user presses cancel. I cannot make the previous solution work (If .Show = -2 Then Exit Sub).
Issue2 = It doesn't remember the variable "target1" when I save the PDF and thus won't select the chosen location. it works when all docs are local on my laptop, but it has fallen over when it tested on the network.

When it works correctly, I'll change the .Show for the .Execute, which means the user has nothing to do except acknowledge the end.

I would very much like some help with identifying what changes need to be made to fix these two issues.

Code:
Private Sub CommandButton1_Click()

Dim MBxAns1 As Long
Dim MBxAns2 As Long
Dim i As Long
Dim target1 As String
Dim filenametitle As String
Dim StrNm As String
Dim vrtSelectedItem As Variant

MBxAns1 = MsgBox("Did you update the SWMS Number?", vbOKCancel, "Bunny Check...")
If MBxAns1 = vbCancel Then Exit Sub


With Application.FileDialog(msoFileDialogFolderPicker)
    .InitialFileName = "G:\Admin - MASTER\Customers"
    .AllowMultiSelect = False
    .Title = "Select Destination Folder for the SWMS"
    If .Show = -2 Then Exit Sub
    target1 = .SelectedItems(1)
End With

MBxAns2 = MsgBox(target1, vbOKCancel, "The Destination Folder is...")
If MBxAns2 = vbCancel Then Exit Sub

 
    With Application.FileDialog(msoFileDialogFilePicker)
        .InitialFileName = "G:\QMS\OH&S"
        .Title = "Select the SWMS Templates"
        .AllowMultiSelect = True
        If .Show = -1 Then
        

          
            For Each vrtSelectedItem In .SelectedItems

                Documents.Open FileName:=vrtSelectedItem
                Options.DefaultFilePath(wdDocumentsPath) = target1
                
                With ActiveDocument
                .Fields.Update
                StrNm = "SWMS " & .Bookmarks("SWMSNumber").Range.Text & " " & _
                .Bookmarks("SWMSType").Range.Text & " - " & _
                .Bookmarks("PrimaryContractor").Range.Text & " - " & _
                .Bookmarks("ProjectName").Range.Text
                .BuiltInDocumentProperties("Title") = StrNm
                .BuiltInDocumentProperties("Subject") = .Bookmarks("SWMSType").Range.Text
                filenametitle = ActiveDocument.BuiltInDocumentProperties("Title")
                 End With
                
                
                With Dialogs(wdDialogFileSaveAs)
                .Name = filenametitle
                .Format = wdFormatPDF
                .Show
                '.Execute
                ActiveDocument.Close SaveChanges:=False


    End With


        Next

        Else

        End If

    End With
    
    MsgBox "remember to secure the PDF before sending"
    ActiveDocument.Close SaveChanges:=False
    
End Sub
Regards from Queensland
Reply With Quote
  #2  
Old 07-16-2014, 06:22 AM
macropod's Avatar
macropod macropod is offline refering to the msoFileDialogueOpen variants Windows 7 32bit refering to the msoFileDialogueOpen variants Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by smndnm View Post
I don't want to open the PDFs, I need to batch process them to apply security settings, it is an attempt to open an instance of Adobe pro locally if not already open.
In that case, you'd probably do better to automate Acrobat Pro (assuming that's what you're using).
Quote:
issue1 = It throws an exception at the"msoFileDialogFilePicker" stage when the user presses cancel. I cannot make the previous solution work (If .Show = -2 Then Exit Sub).
Issue2 = It doesn't remember the variable "target1" when I save the PDF and thus won't select the chosen location. it works when all docs are local on my laptop, but it has fallen over when it tested on the network.
These issues could be avoided if you used the function I provided you with instead of your first call to the file dialogue. All you'd need to call the Function with is:
target1 = GetFolder & "\"
If target1 = "\" Then Exit Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Refering figure number too text danzi Word 1 01-20-2012 12:13 PM
Refering to photos on other pages woodfind Word 1 05-17-2010 01:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:14 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft