Hello clever people,

Completely new to VB.NET (only installed Visual Studio 2019 in the past couple of days).

To start all I want to do is open Excel (office 365) from a button on a userform. The location of the file is on a network, lets say: -

\file-svr01\Rozel\Design\Parts\PNG.xlsx
OR
R:\Design\Parts\PNG.xlsx

I don't need to read in any information from the spread sheet, just open it so thgat i can edit it.

Please bear in mind I am completely new to VB.NET, so if I have to initialise anything in the code before trying to open excel, it would be good if you can put this in any possible solutions.

I have tried using google, I've gone through lots of different web sites and tried lots of things and nothing works, but mainly because I don't really understand the syntax

Can anyone help?

Thanks.

Recommended Answers

You can do this:

Process.Start("EXCEL.EXE", """R:\Design\Parts\PNG.xlsx""")

Documentation:

MSDN

Jump to Post

All 4 Replies

You can do this:

Process.Start("EXCEL.EXE", """R:\Design\Parts\PNG.xlsx""")

Documentation:

MSDN

Thanks for the advice, This is the code I have

    If File.Exists("R:\Design\Parts\PNG.xlsx") Then
        Process.Start("EXCEL.EXE", """R:\Design\Parts\PNG.xlsx""")
    End If

Executing the code, the if statement works because it steps into the process.start, but i get the following message, which I haven't a clue how to solve.

System.ComponentModel.Win32Exception: 'The system cannot find the file specified.'

The file is in the correct location as i can open it by coping the "R:\Design\Parts\PNG.xlsx" and pasting it into windows explorer.

Perhaps the double double quotes are causing this, try:

Process.Start("EXCEL.EXE", "R:\Design\Parts\PNG.xlsx")

Or, excel.exe is not in your path, try specifying the full path.

Thank you for your help, changing to the following works.

Process.Start("C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE", """R:\Design\Parts\PNG.xlsx""")

So, you win the 'Man of the Day' award for your help by offering a simple line of code and helping when it didn't work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.