|
Okay, this seems like a confirmed bug:
http://support.microsoft.com/kb/307230/en-US
The solution is to convert to HTML first, then to xls. The workaround code in VBA:
Sub Macro3()
Dim oXML As Object, oXSL As Object
Set oXML = CreateObject("MSXML.DOMDocument")
Set oXSL = CreateObject("MSXML.DOMDocument")
oXML.Load "c:\customers.xml"
oXSL.Load "c:\customers.xsl"
Dim sHTML As String
sHTML = oXML.transformNode(oXSL)
Open "c:\customers.htm" For Output As #1
Print #1, sHTML
Close #1
Dim oApp As Excel.Application
Set oApp = CreateObject("excel.application")
oApp.Visible = True
oApp.Workbooks.Open "c:\customers.htm"
End Sub
This fails when trying to save the HTML file, presumably because the file cannot be referenced that way in VBScript:
Open "c:\customers.htm" For Output As #1
What do I need to change to save this as HTML?
p.s. I realise this forum is VB but I could not find a disgnated VBScript section
|
|
|
|
|
It fails because you shouldn't write in the root. The PC will explode if you do that.
Member 10666698 wrote: p.s. I realise this forum is VB but I could not find a disgnated VBScript section No surprise there, VBA has been abandoned with VB6.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
While that is good to know I still have no idea how to do this in VBScript. Assume I know nothing about VBScript
|
|
|
|
|
|
Second sentence in that link: Despite Microsoft's best efforts to kill VBA off
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
how to read any specific text from Web Browser tool and put it into TextBox control.
it would be better it you tell me how can i read text line by line from Web Browser tool and put it into TextBox control.
thanks,
Virendra
|
|
|
|
|
Virendra Singh Bhanu wrote: it would be better It would be better if you posted in the ASP.NET forum[^].
|
|
|
|
|
but i don't know ASP.Net
is it not possible in vb.net?
|
|
|
|
|
You have not explained in any detail what you mean by "read line by line from Web Browser tool". However, I would suggest using the WebBrowser Class[^], which allows you to interact with any internet site.
|
|
|
|
|
Did you mean from the WebBrowser control? Or from any browser-application that the user has opened?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
Let's say that I have an object called Employee with the properties Name and Department.
Next I have a List(Of Employee) with say 5 employees in it. Each of these 5 employees are member of one of 10 possible different departments. Perhaps they are each member of a different department, perhaps they are all members of the same department, etc. This is an unknown.
How can I get the distinct departments from my list ?
There is List.Distinct, but it seems I can only get distinct entire objects (employees) through that.
Any help much appreciated.
Best regards,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Probably by creating another List (or other collection class) which only contains departments. Go through all your employee records adding the department to the second list.
|
|
|
|
|
|
Johan Hakkesteegt wrote: Each of these 5 employees are member of one of 10 possible different departments. Perhaps they are each member of a different department, perhaps
they are all members of the same department, etc. This is an unknown. One employee in one department, not one employee in multiple departments. Check.
Imports System.Collections.Generic
Module Module1
Class Employee
Public Property Name As String
Public Property Department As String
End Class
Sub Main()
Dim zeList As New List(Of Employee)
zeList.Add(New Employee() With {.Name = "John", .Department = "IT"})
zeList.Add(New Employee() With {.Name = "Jane", .Department = "IT"})
zeList.Add(New Employee() With {.Name = "Pete", .Department = "Management"})
Dim departments As IEnumerable(Of String) = zeList.Select(Function(e) e.Department).Distinct()
For Each department As String In departments
Console.WriteLine(department)
Next
Console.ReadLine()
End Sub
End Module
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Last night I woke up and figured Richard's answer myself, but this is the "one-liner" that I was after.
Thanks Eddy !
My advice is free, and you may get what you paid for.
|
|
|
|
|
Eddy Vluggen wrote: zeList.Select(Function(e) e.Department).Distinct()
I looked and looked and wondered where the Function(e) comes from and what is it doing x=>
So I have not looked at VB since before linq was invented.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
How do I keep a class object "alive" in a Windows Service?
I have a simple class object (clsWatcher) that monitors a folder using an instantiation of the FileSystemWatcher class. It works great. When a change is made to the folder being "watched" it triggers a log entry.
When I use the clsWatcher as a form-level object in a standard Windows Forms EXE, it works perfectly as long as the windows form is open. When the form closes, it dies and no watching is done. Perfect.
When I transfer this class to a SYSTRAY application, it continues to work correctly. As long as the SYSTRAY application is not exited, the clsWatcher works properly. When I exit the SYSTRAY application, it dies and no watching is done. Perfect.
When I transfer this class to a Windows Service, it does not work as desired. The service starts, the clsWatcher instantiates, and then the service "finalizes" and the clsWatcher dies even though the service is still "started" and no errors were logged (I have an Application Log feature to send messages that can be observed during start up and errors.)
How do I keep the service/application "running" in order to keep the instantiated clsWatcher object alive?
|
|
|
|
|
ToolTimeTabor wrote: and then the service "finalizes" What does that mean? Does the service crash? Is yourservice.exe still in the list of processes in the task manager ("show processes of all users")?
|
|
|
|
|
ToolTimeTabor wrote: How do I keep the service/application "running" Create an infinite loop (and exit if Windows is shutting down). A service doesn't have a loop that keeps the app alive until someone "closes" it, as it should not be closed.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have a very similar windows service that does exactly what you are describing.
Dim watcher As New FileSystemWatcher()
watcher.Path = gsWatcherPath
watcher.NotifyFilter = (NotifyFilters.LastAccess Or NotifyFilters.LastWrite Or NotifyFilters.FileName Or NotifyFilters.DirectoryName)
watcher.Filter = "*.txt"
AddHandler watcher.Created, AddressOf OnChanged
watcher.EnableRaisingEvents = True
Private Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs)
Call ProcessFile_Master(e.FullPath)
End Sub
Once you instantiate the FileSystemWatcher, there is nothing else to do, no loops, nothing extra.
The Sub, OnChanged, gets fired for each file that is changed in the "watched" directory.
Hope this helps.
|
|
|
|
|
I am trying to write code for multiple if/and statements, but don’t really know how. Any help would be very much appreciated!
I need the code to loop through these statements and enter the correct information in cell M5.
IF C9= ”SHIP EXACT” AND G13<c13, then="" m5="”ENTER" remake”
if="" c9="”" no="" backorders="" on="" stock="" unless="" zero="" were="" shipped”="" and="" g13<c13,="" remake="" required”
if="" ship="" tolerance”="" g13="" c13="">10%, then M5= “ENTER REMAKE”
IF C9= ”5% Ship Tolerance” AND G13/C13>5%, then M5= “ENTER REMAKE”
|
|
|
|
|
First, phase them in your natural language, such as English:
If I score 90 and above,
then my grade is 'A'
Else If I score 80 and above (but below 90 - this one can be omitted as it would have been considered in the first if statement)
then my grade is 'B'
else If I score 70 and above
then my grade is 'C'
...
Else (last condition no need to have condition, it is understood to be none of the above)
the my grade is 'F'
Finally, print out my grade
Once you are satisfied with these statement, then translate them to vb.net code.
refer: If...Then...Else Statement (Visual Basic)[^]
|
|
|
|
|
You should use
if [condition] then
[result]
else if [condition2] then
[result2]
end if
Since when is being together a prerequisite for being in love with someone?
|
|
|
|
|
Hi guys,
i have codes that displaying different images as gif in one picturebox. My problem is, how can i save this .gif i mydocuments?
here is my codes..
thank you in advance!
Public Class Form7
Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.BackColor = Color.Ivory
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
TextBox1.Text = (OpenFileDialog1.FileName)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
TextBox2.Text = (OpenFileDialog1.FileName)
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
TextBox3.Text = (OpenFileDialog1.FileName)
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
TextBox4.Text = (OpenFileDialog1.FileName)
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
TextBox5.Text = (OpenFileDialog1.FileName)
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
TextBox6.Text = (OpenFileDialog1.FileName)
End If
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
TextBox7.Text = (OpenFileDialog1.FileName)
End If
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
TextBox8.Text = (OpenFileDialog1.FileName)
End If
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Timer1.Enabled = True
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim max As Integer = 500
Dim rnd As New Random
Dim rand As Integer = rnd.Next(5, max + 1)
Dim i As Integer = 1
Dim number(max - 1) As Integer
For i = 0 To max - 1
If number(i) = rand Then
rand = rnd.Next(1, max + 1)
i = -1
ElseIf number(i) = 0 Then
number(i) = rand
rand = rnd.Next(1, max + 1)
If i = max - 1 Then
Exit For
End If
i = -1
End If
Next
Timer1.Interval = number(i)
i += 1
ChangeImage()
End Sub
Private Sub ChangeImage()
Static Dim iImage1 As Integer
Select Case iImage1
Case 0
PictureBox1.Visible = True
PictureBox1.Image = Image.FromFile(TextBox1.Text)
iImage1 += 1
Case 1
PictureBox1.Visible = True
PictureBox1.Image = Image.FromFile(TextBox2.Text)
iImage1 += 1
Case 2
PictureBox1.Visible = True
PictureBox1.Image = Image.FromFile(TextBox3.Text)
iImage1 += 1
Case 3
PictureBox1.Visible = True
PictureBox1.Image = Image.FromFile(TextBox4.Text)
iImage1 += 1
Case 4
PictureBox1.Visible = True
PictureBox1.Image = Image.FromFile(TextBox5.Text)
iImage1 += 1
Case 5
PictureBox1.Visible = True
PictureBox1.Image = Image.FromFile(TextBox6.Text)
iImage1 += 1
Case 6
PictureBox1.Visible = True
PictureBox1.Image = Image.FromFile(TextBox7.Text)
iImage1 += 1
Case 7
PictureBox1.Visible = True
PictureBox1.Image = Image.FromFile(TextBox8.Text)
iImage1 += 1
Case 8
PictureBox1.Visible = True
PictureBox1.Image = Image.FromFile(TextBox9.Text)
iImage1 += 1
Case 9
PictureBox1.Visible = True
PictureBox1.Image = Image.FromFile(TextBox10.Text)
iImage1 = 0
End Select
End Sub
End Class
modified 13-May-14 3:20am.
|
|
|
|
|
You have already asked once - please don't repost
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|