Question

Always asked what app to open jpg files

  • 18 August 2023
  • 22 replies
  • 215 views

Userlevel 2
Badge +6

Hello,

Every time I open a jpg attachment in apps 10 IEE, I get the “How do you want to open this file?” prompt by Windows, and regardless of how many times I check the “always use this app to open .jpg files” checkbox, I always get this prompt when I open a jpg attachment. I know Windows is storing this app as the default program because Windows never prompts me with this when I open jpgs via other methods like email attachments, locally saved jpgs, network pictures, etc. It’s only occurring when I open a jpg via the IEE app. I can even navigate to the folder where IFS downloads the jpg file and open it successfully from there. 

I’ve tried resetting the Photos app in Windows and re-confirming the default app choices in app settings. I’ve spoken to other users of our apps 10 IEE setup and they don’t appear to have this same issue. Any thoughts on how to remedy this?

Thanks,

Evan Edwards


22 replies

Userlevel 7
Badge +30

I have seen strange things happening with some image formats on Windows. It started some years back. I know it's probably not the app you want to use, but what happens if you chose Paint the next time? Does that also not stick?

Userlevel 2
Badge +7

HI,

You could also check your default app for the file type to see if the action actually saves your preference for the default file types in the settings. This can be found from Microsoft’s own settings: settings---applications---choose default apps by file type (scroll down to find this)

 

Here is a screenshot of the setting:

 

Userlevel 2
Badge +6

@Mathias Dahl

I opened a jpg file and when the program pop up came up this time, I selected Paint and checked the box to always use this app and it opened the image in paint. But now when I try open the jpg attachment, I get this error. I haven’t seen this error before. Windows did keep Paint as the default app though because if I open a jpg saved locally, it opens in paint without issues.

I then switched the default program back to the Photos app in Windows. I’m able to open the jpg attachment from IFS without the error message above, but it still gives me the which app do you want to use pop up each time.

I don’t know if this helps or not, but I previously used a desktop tower and a Microsoft Surface laptop from when we started implementation of IFS (2021) until June of this year. I never had this issue with both the desktop tower and the Microsoft Surface. My devices got consolidated to a Dell laptop in June of this year, and that seems to be when this issue started happening. Not sure if this is coincidental or not.

Userlevel 2
Badge +6

@Samuel Jokinen 

Below is a screenshot showing the default program by file type. I’ve tried changing and resetting these to the Photos app again, but I still get the which app do you want to use pop up each time.

 

Userlevel 7
Badge +30

Would you be willing to configure a Docman macro to resolve the issue? It will probably do the trick?

Userlevel 2
Badge +6

@Mathias Dahl 

Sure, I’d be willing to try anything, but I haven’t done any docman macros before. How would I go about doing this?

Thanks,

Evan Edwards

Userlevel 7
Badge +30

@Mathias Dahl

Sure, I’d be willing to try anything, but I haven’t done any docman macros before. How would I go about doing this?

Thanks,

Evan Edwards

Hi @eedwards , sorry for the late reply.

Firstly, you should read our documentation about what document macros are, and how to install them:

https://docs.ifs.com/ifsclouddocs/21r2/CreateAndMaintainDocument/AboutDocumentMacro.htm?StandAlone=true

That documentation is for IFS Cloud, but it doesn't matter since the concepts are exactly the same.

Next, define the following two macro blocks under Macro Basic - Document Macro Blocks:

Block Name: UTILS

Script:

' ------------------ Macro block UTILS starts here

' Some utility functions

Public Function GetAttr (name)

  On Error Resume Next

  Err.Clear

  Dim value

  Dim obj

  value = ScriptValues.Item(UCase(name)).Value

  If Err.Number <> 0 Then

     MsgBox "Could not get attribute """ & UCase(Name) & _

            """. It might be misspelled. Error: " & Err.Description

    Err.Clear

  End If

  

  GetAttr = value

End Function

Public Function GetClientAttr (name)

  On Error Resume Next

  Err.Clear

  Dim value

  Dim obj

  value = ClientScriptValues.Item("LOCAL_FILE_1").Value

  If Err.Number <> 0 Then

     MsgBox "Could not get client attribute """ & UCase(Name) & _

            """. It might be misspelled. Error: " & Err.Description

    Err.Clear

  End If

  

  GetClientAttr= value

End Function

Public Function SlashToBackslash (str)

  SlashToBackSlash = Replace(str, "/", "\")

End Function

Public Sub OpenFile (filename)

    Set shell = CreateObject("WScript.Shell")

    shell.Run filename

End Sub

' ------------------ Macro block UTILS ends here

Block Name: OPENFILE

Script:

' ------------------ Macro block OPENFILE starts here

Public Sub OpenDownloadedFile

  Dim filename

  Dim twoNewLines

  Dim answer

  Dim oShell

  twoNewLines = Chr(10) & Chr(10)

   

  filename = SlashToBackslash(GetClientAttr("LOCAL_FILE_1"))

  Set oShell = CreateObject("Shell.Application")

 ' Below, "Open" can be replace by "Print" for printing the file

 ' instead of opening it.

     

 oShell.ShellExecute fileName, "", "", "Open" 

End Sub

' ------------------ Macro block OPENFILE starts here

Then, create a new record under the Document Macro tab (follow the steps in the documentation) and add the two macro blocks defined earlier in the table at the bottom of the page.

This macro does more or less what Docman normally does, it asks Windows to open the file. But it's not doing it in the exact same way, so it might work better for you.

If the macro does not work, it can easily be made to force a certain application to open the file.

Let me know if you have any questions.
 

Userlevel 7
Badge +30

Perhaps a screenshot of the setup helps:

 

Userlevel 7
Badge +30

Now when you view a JPG file, the macro will take care of opening the file.

Userlevel 7
Badge +30

Also see:

 

Userlevel 7
Badge +30

I forgot something: you probably don't want to click Run Macro to run the macro, you want it to run automatically. You configure this by going to Document Class Process Action and create a new record there for the document class you want to configure, and the process (view). In the macro option field, select "Run of only one". You need to do this for all document classes that has JPEG images checked in.

Userlevel 7
Badge +30

I forgot something: you probably don't want to click Run Macro to run the macro, you want it to run automatically. You configure this by going to Document Class Process Action and create a new record there for the document class you want to configure, and the process (view). In the macro option field, select "Run of only one". You need to do this for all document classes that has JPEG images checked in.

This is how it can look:

Hope this helps!

@eedwards 

 

Userlevel 7
Badge +30

@eedwards Did you try this out? Did it work?

Userlevel 2
Badge +6

Hi @Mathias Dahl ,

I apologize for the large delay in my response. I had some long training and conferences I was attending recently and did not have a chance to test this out until now.

I’m testing this out in one of our test environments, and I’m running into a syntax error when attempting to run the macro. 

I’ve set up both macro blocks under the Document Macro Blocks using the code strings from above:

Then I created the new macro under the Document Macro tab following the instructions and screenshot:

The macro seems to be initializing properly because when I try open jpg file, I get the Choose Macro prompt (I haven’t set up the document class process action yet just to make sure the macro was running properly). When I click Run on the Open file in Windows macro, I get this syntax error message: 

I’m assuming this is meaning there’s a syntax error in one of the macro blocks, but I’m not very familiar with the visual basic programming language to be able to debug what the error might be. Any thoughts on this?

Userlevel 7
Badge +30

I'm pretty sure I tested those macro blocks myself, so they should not have any syntax errors. Perhaps something went wrong when copying and pasting them?

Can you provide screenshots of the macro blocks here?
 

Userlevel 2
Badge +6

I tried running these through a word comparison and it didn't really find any mismatches. Here are screenshots of the macro blocks as they are pasted in IFS:

UTILS

OPENFILE

 

Userlevel 7
Badge +30

Strange. Can you try, temporarily, with a macro that only shows a message box? It's described in the documentation. We need to determine that macros can run at all.

Userlevel 2
Badge +6

Hi Mathias,

 

I’ve narrowed it down to a syntax error somewhere in the UTILS macro block. I created a new macro block called HELLO that just runs a message box saying Hello!.

I then changed the document macro for opening jpg to just have that macro block associated to it. When I opened a jpg file, I successfully got the message box pop up. I then added the OPENFILE macro block and was still able to successfully get the hello message box pop up. I deleted the OPENFILE macro block and added UTILS and when I try open a jpg file, I get the syntax error pop up instead of the hello message box.

Userlevel 2
Badge +6

I also accidentally stumbled across that this issue only seems to apply to images that are loaded into IFS with the file extension of .jpg. I don’t get the window requesting to select the program to load images that are loaded in with the .jpeg extension. I’m not sure if this helps at all, just an odd thing I stumbled across troubleshooting the above macro issue.

Userlevel 7
Badge +30

@eedwards 

Hi again.

I think I know what the problem is. When you copy the source code from the post above, you will get an extra empty line per line of code (it's a problem with the text editor on this site, it's not in the original source code I wrote).

For many lines it does not matter, but in some case it does:

1 If Err.Number <> 0 Then

2

3  MsgBox "Could not get attribute """ & UCase(Name) & _

4           

5           """. It might be misspelled. Error: " & Err.Description

Line 3 there has an underscore at the end. It means the line continues on the next line. But, since the next line is an empty line, you get a syntax error.

The solution is to remove the empty line after all lines that end with "_" like line 3 above.

I found this by copying the code into a test.vbs file that I just ran on my PC. It then showed the line number where the problem is.

As for .jpg vs .jpeg, since they are two different file extensions for the same kind of files, both Windows and IFS will see them as different and, for some reason, one is setup correctly in Windows and the other one not.

Hope you can get this to work now.

Userlevel 2
Badge +6

Hi Mathias,

This solved the syntax errors I was getting. I fixed the instances of this and it allowed the macro to run without issues next time I opened a jpg. Unfortunately, Windows still asked me what program I’d like to use each time regardless of me checking the “always use this program” checkbox. I just found out form our IT group that my computer is going to be upgraded to Windows 11 in the next week or so, so I’ll test after that again to see if the operating system change makes any difference. I’ve tested with a few other users at our company and none of them are having this issue with opening jpg files though.

Thanks,

Evan Edwards

Userlevel 7
Badge +30

Now that macros are running, what you can do is to have the macro explicitly open the file in a specific application. I asked ChatGPT to write an example program for doing that:

 

Set objShell = CreateObject("WScript.Shell")

jpegFilePath = "C:\path\to\your\image.jpg" ' Replace with the actual path to your JPEG file

' Check if the file exists

If objFSO.FileExists(jpegFilePath) Then

    ' Open the JPEG file with Microsoft Paint

    objShell.Run "mspaint.exe """ & jpegFilePath & """", 1, True

Else

    MsgBox "File not found: " & jpegFilePath

End If

 

Perhaps you can try taking parts of that and add to your current macro?

 

Reply