Open form, populate once open, but wait before continuing code. Modal not suitable (1 Viewer)

bignose2

Registered User.
Local time
Today, 21:49
Joined
May 2, 2010
Messages
219
Hi,

Think should be able to work this out for myself but struggling
I have a form with a web browser control.
I want to view the pdf then decide which folder to save it to, so after closed immediately have the choose folder (ApplicationFileDialog.. stuff

I open the form, then once open & ready, load the document (often a PDF but could be jpg etc)
I do this after as use the same webform from different locations & also prefer no buttons on the subform
I found that this method of webcontrol just works best for general use rather that trying to set source etc.

Of course if opened ,,,,,acDialog it does not do the Forms!WBSubForm.WB1.Navigate bit.

Any ideas?
many thanks I/A.

Code:
    strInputFileName = VarDirectory & "\" & Me!AttachmentsList   ' caution no forward /. else get virus warning check
'    Application.FollowHyperlink strInputFileName
    
    stdocname = "WBSubForm"
    DoCmd.OpenForm stdocname
    Do Until Forms!WBSubForm.WB1.Object.ReadyState = AcWebBrowserState.acComplete
       '  Debug.Print Forms!WBSubForm.WB1.Object.ReadyState
        DoEvents
    Loop
    Forms!WBSubForm.WB1.Navigate (strInputFileName)   '(Forms!emailPaste!SendAttachment)
  
  
        
    ' #######LATEBINDING - did not need anymore that this, no ref. needed ###########
    With Application.FileDialog(4)      ' was 3, think 4 is Folder picker -
        .AllowMultiSelect = False 'Select only one file
        .Title = "Choose Folder To Put In" 'Set dialog title
        .ButtonName = "Select Folder" 'Set the button caption
        .Filters.Clear 'Make sure the filter list is clear
        .InitialFileName = VarDirectory 'Initial file search location
        .InitialView = 1 'View as list    msoFileDialogViewList
        'Show the dialog and test the return
        If .Show = 0 Then 'didn't pick a file - exit sub
            Exit Sub
        Else
            Debug.Print .SelectedItems(1)
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:49
Joined
Feb 19, 2013
Messages
16,616
why not just put your code in the form open, load or current event?

or move your docmd.openform to after user has selected the file and pass the file path as an openarg
 

bignose2

Registered User.
Local time
Today, 21:49
Joined
May 2, 2010
Messages
219
It may be different or a better way now but I know long time ago when I originally worked on the web control, I spent a very long time trying different methods & opening & using the readystate made it work well otherwise I think was often not populated.
Don't really want to revisit the whole process as I say used frequently in different parts of the program.

same applies to not being too keen on adding to the subform in on open, I could use openargs to run different code depending on the calling form but just would prefer this way round.
I figured there should be a way but appreciate may be more of a mess than somehow doing it on open.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:49
Joined
Feb 19, 2002
Messages
43,281
I don't use the web control to open documents. They always look too small to me. So I don't have any wisdom to offer. I use FollowHyperlink. That opens the file using its native program whatever that might be. You could then use save as using whatever program opened the file. I'm trying to envision the process and it feels like that would be equivalent to what you want to do.
 

Users who are viewing this thread

Top Bottom