Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15589

VS 2017 [RESOLVED] My Form is on top of my Word document that I have just opened

$
0
0
I am quite a rookie on VB.net, but have been programming one way or another for over 40 years, I still have trouble getting my head around things, hence my probably very simple question ...

I have the following code that works, but my Form is reappearing on top of the just opened Word document. How can I make the Word document appear on top ?

I am still in Debug mode, but presume that makes no difference ...

Thanks in advance ...

Code:

Imports Microsoft.Office.Interop.Word
Imports Microsoft.Office.Interop

Public Class Form2
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If TextBox1.Text = "" Then
            Form3.TextBox1.Text = "Error, you have not entered a name for this Artist or Band ..."
            Form3.TextBox2.Visible = False
            Form3.Button2.Visible = True
            Form3.AcceptButton = Button2
            Form3.Show()
            Exit Sub
        End If
        MusicFile = TextBox1.Text & ".docx"
        If System.IO.File.Exists(MusicFolder & MusicFile) Then
            Form3.TextBox1.Text = "Error, you already have an existing file for this Artist or Band ..."
            Form3.TextBox2.Text = "Do you want to open that file or go back to the previous screen ?"
            Form3.Button1.Visible = True
            Form3.Button3.Visible = True
            Form3.AcceptButton = Button1
            Form3.Show()
        Else
            If SheetOrientation = "Portrait" Then
                System.IO.File.Copy(MusicFolder & "Portrait.docx", MusicFolder & MusicFile)
            End If
            If SheetOrientation = "Landscape" Then
                System.IO.File.Copy(MusicFolder & "Landscape.docx", MusicFolder & MusicFile)
            End If
            System.IO.File.SetAttributes(MusicFolder & MusicFile, fileAttributes:=vbNormal)
            WordApp = CreateObject("Word.Application")
            WordApp.Visible = True
            WordDoc = WordApp.Documents.Add(MusicFolder & MusicFile)
            Me.Close()
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
End Class

Attached Images
 

Viewing all articles
Browse latest Browse all 15589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>