Results 1 to 10 of 10
  1. #1
    Stan Denman is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    50

    VBA code treated as"Malicious"


    I am trying to run this code from an microsoft access form. It seeks to fill an adobe acrobat form from MS access data on the form. I runs fine when I am referring to a pdf on my desktop. I am trying to have the code load a tempate from my online adobe account.
    Code:
    rivate Sub Command85_Click()    Dim TemplateURL As String
        Dim DownloadFolder As String
        Dim DownloadPath As String
    
    
        ' Define the URL of your Adobe Acrobat template
        TemplateURL = "Url of my template"
    
    
        ' Define the folder where you want to save the downloaded template
        DownloadFolder = "C:\Users\stand\Desktop\"
    
    
        ' Generate a unique file name
        DownloadPath = DownloadFolder & "template_" & Format(Now, "YYYYMMDDHHMMSS") & ".pdf"
    
    
        ' Download the template from the URL
        If DownloadFile(TemplateURL, DownloadPath) Then
            ' Open the downloaded PDF in Adobe Acrobat
            Shell "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe """ & DownloadPath & """", vbNormalFocus
        Else
            MsgBox "Template download failed."
        End If
    End Sub
    
    
    Function DownloadFile(URL As String, FilePath As String) As Boolean
        On Error Resume Next
        Dim WinHttpReq As Object
        Set WinHttpReq = CreateObject("MSXML2.ServerXMLHTTP")
    
    
        WinHttpReq.Open "GET", URL, False
        WinHttpReq.send
    
    
        If WinHttpReq.status = 200 Then
            Dim objStream As Object
            Set objStream = CreateObject("ADODB.Stream")
            objStream.Open
            objStream.Type = 1
            objStream.Write WinHttpReq.responseBody
            objStream.Position = 0
            objStream.SaveToFile FilePath
            objStream.Close
            DownloadFile = (Err.Number = 0) ' Check if an error occurred during the save operation
        End If
    
    
        Set WinHttpReq = Nothing
        On Error GoTo 0
    End Function
    Antivirus shuts it down. I don't want to just shut the antivirus down to solve obviously.
    Click image for larger version. 

Name:	screenshotforAccessForum.jpg 
Views:	26 
Size:	114.4 KB 
ID:	50907

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Does the file have the "Mark of the Web"?

    Check the file properties and see if it is blocked.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  4. #4
    Stan Denman is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    50
    I don't know what we mean by "the file". I am going to assume the target template file. I don't know what you mean by "blocked". And I don't know what you mean by "Mark of the Web".

  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654


    https://learn.microsoft.com/en-us/deployoffice/security/internet-macros-blocked




    check your downloaded file.
    Also check trusted location.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #6
    Stan Denman is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    50
    I am dealing with a pdf file not a word file.

  7. #7
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    It applies to ANY downloaded file.

  8. #8
    Stan Denman is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    50
    The problem appears to be with MS Access setting (thank you ChatGPT). Going in the "Trust Center" in MS Access and setting permission for all macros did allow for download. Still having problems in that I am downloading an html not a pdf file, and therefore will not work. Tyring now to figure out how to get the correct url for the pdf template. Thanks very much for your hlep!

  9. #9
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    I'm not sure what an Adobe online account entails, but have you looked through their API's to see if there's anything relevant?

    https://developer.adobe.com/apis
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  10. #10
    Stan Denman is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    50
    That is a good idea. Thank you for the suggestion and the link.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 11-14-2019, 11:30 AM
  2. Can't test code - "Debug" - "Run to Cursor"
    By GraeagleBill in forum Programming
    Replies: 4
    Last Post: 05-15-2016, 05:16 PM
  3. Replies: 2
    Last Post: 12-23-2015, 09:32 PM
  4. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  5. Replies: 4
    Last Post: 07-12-2014, 02:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums