|
Show us some code, for each of the two questions you have. However, e-mails might not be sendt an masse, as some providers have rules on how many can be sendt as a SPAM filter.
|
|
|
|
|
Hello,
I would like to make a duplicate of the currently open document via a VBA macro.
That is, when running the macro, it will use the current active document as source and make a copy of it without saving it to a file.
The current document may be modified (changes were not yet saved to a file), and it could be based on a specific template, with headers/footers/fields.
The new copy, should have an identical content (including headers/footers/fields) as the original, based on the same template but with a new name and not saved to a file yet. (The user may save it later if required)
Is this possible?
Thanks in advance.
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
Perhaps something like this will work for you.
Sub CopyDoc()
Dim sourcedoc As Document
Set sourcedoc = Application.ActiveDocument
Dim newdoc As Document
Set newdoc = Application.Documents.Add(Template:=sourcedoc.AttachedTemplate.FullName, Visible:=True)
sourcedoc.Range.Copy
newdoc.Range.Paste
sourcedoc.Activate
Set sourcedoc = Nothing
Set newdoc = Nothing
End Sub
|
|
|
|
|
I have been working on a minecraft (game) launcher and so far everything is going good. But I want it to do something more.. like install different versions. The way the official launcher does it by reading the .json file. Here is an example of one of the json file:
{
"id": "1.6.4",
"time": "2013-09-19T20:52:37+05:00",
"releaseTime": "2013-09-19T20:52:37+05:00",
"type": "release",
"minecraftArguments": "--username ${auth_player_name} --session ${auth_session} --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}",
"libraries": [
{
"name": "net.sf.jopt-simple:jopt-simple:4.5"
},
{
"name": "com.paulscode:codecjorbis:20101023"
},
{
"name": "com.paulscode:codecwav:20101023"
},
{
"name": "com.paulscode:libraryjavasound:20101123"
},
{
"name": "com.paulscode:librarylwjglopenal:20100824"
},
{
"name": "com.paulscode:soundsystem:20120107"
},
{
"name": "argo:argo:2.25_fixed"
},
{
"name": "org.bouncycastle:bcprov-jdk15on:1.47"
},
{
"name": "com.google.guava:guava:14.0"
},
{
"name": "org.apache.commons:commons-lang3:3.1"
},
{
"name": "commons-io:commons-io:2.4"
},
{
"name": "net.java.jinput:jinput:2.0.5"
},
{
"name": "net.java.jutils:jutils:1.0.0"
},
{
"name": "com.google.code.gson:gson:2.2.2"
},
{
"name": "org.lwjgl.lwjgl:lwjgl:2.9.0",
"rules": [
{
"action": "allow"
},
{
"action": "disallow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl_util:2.9.0",
"rules": [
{
"action": "allow"
},
{
"action": "disallow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.0",
"rules": [
{
"action": "allow"
},
{
"action": "disallow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
],
"natives": {
"linux": "natives-linux",
"windows": "natives-windows",
"osx": "natives-osx"
},
"extract": {
"exclude": [
"META-INF/"
]
}
},
{
"name": "org.lwjgl.lwjgl:lwjgl:2.9.1-nightly-20130708-debug3",
"rules": [
{
"action": "allow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl_util:2.9.1-nightly-20130708-debug3",
"rules": [
{
"action": "allow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.1-nightly-20130708-debug3",
"rules": [
{
"action": "allow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
],
"natives": {
"linux": "natives-linux",
"windows": "natives-windows",
"osx": "natives-osx"
},
"extract": {
"exclude": [
"META-INF/"
]
}
},
{
"name": "net.java.jinput:jinput-platform:2.0.5",
"natives": {
"linux": "natives-linux",
"windows": "natives-windows",
"osx": "natives-osx"
},
"extract": {
"exclude": [
"META-INF/"
]
}
}
],
"mainClass": "net.minecraft.client.main.Main",
"minimumLauncherVersion": 4,
"synced": false
}
I wanted to know how to read this (format it) properly. Example the above gets formated as:
-Djava.library.path=[]versions\1.6.4\1.6.4_TagCraftMC -cp []libraries\net\sf\jopt-simple\jopt-simple\4.5\jopt-simple-4.5.jar;[]libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar;[]libraries\com\paulscode\codecwav\20101023\codecwav-20101023.jar;[]libraries\com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar;[]libraries\com\paulscode\librarylwjglopenal\20100824\librarylwjglopenal-20100824.jar;[]libraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar;[]libraries\org\lwjgl\lwjgl\lwjgl\2.9.0\lwjgl-2.9.0.jar;[]libraries\org\lwjgl\lwjgl\lwjgl_util\2.9.0\lwjgl_util-2.9.0.jar;[]libraries\argo\argo\2.25_fixed\argo-2.25_fixed.jar;[]libraries\org\bouncycastle\bcprov-jdk15on\1.47\bcprov-jdk15on-1.47.jar;[]libraries\com\google\guava\guava\14.0\guava-14.0.jar;[]libraries\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar;[]libraries\commons-io\commons-io\2.4\commons-io-2.4.jar;[]libraries\net\java\jinput\jinput\2.0.5\jinput-2.0.5.jar;[]libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar;[]libraries\com\google\code\gson\gson\2.2.2\gson-2.2.2.jar;[]versions\1.6.4\1.6.4.jar net.minecraft.client.main.Main --username ~ --session - 0 --version 1.6.4 --gameDir| --assetsDir []assets
where ~ is username
[] and | is the %appdata% folder
I can format it manually using a notepad but this takes a lot of time and the process isn't automated. The above is an argument which needs to be passed in order to make the game run.
Any help regarding this would be appriciated
modified 17-Oct-13 14:29pm.
|
|
|
|
|
For reading or writing JSON in .NET, the best place to start is the JSON.NET[^] library.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Dear sir,
I made a project in Visual basic and sql server table,i made a window form where i placed a data grid, in data grid the header and data populated from database table, but i want to change the datagrid column header (not database table column)and populate the data from table programmatically.
|
|
|
|
|
You change the column headers by aliasing the columns in your SQL statement
eg
SELECT Firstname as Forename, LastName as Surname FROM tblPerson
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
|
You want to use something like:
gridView.Columns("yadayadayada").HeaderText = "UseTheForce"
DisplayIndex is also worth looking at as it will allow you to re-order the columns.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
dear all,
i want to read a dxf and extract entities data for polyline to be used later
i already read the dxf file but i do not have any idea how to extract the required section from it
my code was
Public Sub Dxf_Reader(ByVal file As String)
Dim tag As IO.StreamReader
Dim txtarray As String()
If infile = "" Then Exit Sub
tag = IO.File.OpenText(infile)
txtarray = tag.ReadToEnd().Split(New String(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries))
tag.Close()
End Sub
|
|
|
|
|
|
Apologoes if this the wrong forum – could be in “Database”, or even C# - it’s a bit of a cross-over...
The scenario:
I have a database table holding records of items that are flagged according to various key terms held in another table – eg:
keywords table:
ID – integer
sKeyword – string
There are about a dozen of these, which won’t change, with ID’s from 1 to 12.
items table:
ID – integer
iKeywords – Double
(other fields)
The iKeywords number is calculated simply as the sum of 2 ^ keywords.ID for all relevant keywords. A record may be associated with multiple keywords. Thus it is easy to select records matching keywords criteria, and updating records is similarly easy.
The problem:
Give the iKeyword value of a particular item, find other items which are matched with some or all of the keywords of this record, ordered by the number of matching keywords.
The solution...?
Apart from an obvious brute-force approach, I am sure there must be an elegant algorithm (c# or vb .NET preferably) that can do it.... even better a really smart SQL statement, but that’s probably hoping for too much.
Or maybe I should be approaching the database structure differently?
|
|
|
|
|
Why is your iKeywords field is a double if you only have 12 keywords and they're not going to change? A 16-bit integer (smallint ) would be sufficient.
The design feels wrong; the standard approach would be to have a many-to-many relationship between the keywords and the items:
Keywords: KeywordID [PK], Keyword
Items: ItemID [PK], ...
ItemKeywords: ItemID [PK, FK], KeywordID [PK, FK]
This would lead to a fairly simple solution:
SELECT
B.ItemID,
Count(1) As MatchedKeywordCount
FROM
ItemKeywords As A
INNER JOIN ItemKeywords As B
ON A.KeywordID = B.KeywordID
WHERE
A.ItemID = @ItemToMatch
And
B.ItemID != @ItemToMatch
GROUP BY
B.ItemID
ORDER BY
MatchedKeywordCount DESC
;
With your current implementation (updated to use an integer type for iKeywords ), you can identify matching products using bitwise-AND[^]:
SELECT
...
FROM
Items
WHERE
(iKeywords & @KeywordsToMatch) != 0
;
Counting the number of matching keywords is slightly more complicated. For example:
WITH N0 (X) As
(
SELECT 1
UNION ALL
SELECT 1
),
N1 (X) As
(
SELECT 1
FROM N0 A CROSS JOIN N0 B
),
N2 (X) As
(
SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) - 1
FROM N1 A CROSS JOIN N1 B
),
PowersOfTwo (Value) As
(
SELECT Power(2, X)
FROM N2
),
MatchingItems As
(
SELECT
I.ItemID,
I.iKeywords & @KeywordsToMatch As MatchedKeywords
FROM
Items As I
WHERE
(I.iKeywords & @KeywordsToMatch) != 0
)
SELECT
I.ItemID,
Count(1) As MatchedKeywordCount
FROM
MatchingItems As I
INNER JOIN PowersOfTwo As P
ON (I.MatchedKeywords & P.Value) != 0
GROUP BY
I.ItemID
;
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Many thanks for this - should be enough to get me going!
I used a double only because when I began I wasns't sure of the exact keyword list, so played safe in case there were more. I agree the design "looks wrong" as it is clearly limited to only a relatively small number of keywords. I'll have a play with doing it right!
|
|
|
|
|
Sir Please tell me how to run an external exe in a frame in vb.net... it is possible...
|
|
|
|
|
Member 10279246 wrote: external exe in a frame in vb.net WinForms does not have a "frame" concept. You can change the parent of a running executable to point to your Window, as you already did. SetWindowLong[^] is used to change the border. The statusbar and toolbars aren't part of that border. The borderstyles can be found on P/Invoke[^].
..and please don't repost the exact same question. People tend to ignore duplicate posts.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Which part of "don't repost" did you not understand?
You have now posted the same question twice in this forum, and twice in QA. You haven't even had the courtesy to respond to the people who have tried to answer your previous versions of this question.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
No you can't.
You can, however, open and run an external program from VB.Net.
|
|
|
|
|
Actually, you can do that. It's not very nice looking and you don't have control over the application window nor with the application itself. The user can do whatever they want with application, including putting it back to windowed mode and moving it around inside your parent window, even to the point where they can't see the window any more.
|
|
|
|
|
I want to run ms word application in my program... I have call the exe but I want to run under a frame means I do not want to show the border..
or any method to remove the frame or border of external exe
here is sample code which I got but not working
-----------------------------------------
Public Class Form1
Inherits System.Windows.Forms.Form
Declare Function ShowWindow Lib "user32" (ByVal hWnd As System.IntPtr, ByVal nCmdShow As Integer) As Boolean
Private Const SW_MINIMIZE As Integer = 6
Private Const SW_MAXIMIZE As Integer = 3
Private Const SW_RESTORE As Integer = 9
Declare Function SetParent Lib "user32" (ByVal hWndChild As System.IntPtr, ByVal hWndNewParent As System.IntPtr) As System.IntPtr
#Region " Windows Form Designer generated code "
Private Sub wordMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles wordMenu.Click
Dim pinfo As New ProcessStartInfo("WINWORD")
Dim p As Process = System.Diagnostics.Process.Start(pinfo)
p.WaitForInputIdle()
SetParent(p.MainWindowHandle, Label1.Handle)
End Sub
End Class
'Here this fellow explain how to run winword under a label.. But it is not working.... or any method to remove frame of called exe
|
|
|
|
|
Member 10279246 wrote: Here this fellow explain how to run winword under a label.. But it is not working. Then you should go and ask him for help.
Veni, vidi, abiit domum
|
|
|
|
|
Kindly don't repost - I saw the same question in Q&A.
You won't be able to remove the border of the external exe unless you have their source code and can pass a parameter that suggests you are launching this program from another location.
|
|
|
|
|
i have made a table
plotno int Not Null
plotsize varchar(10) Allow Null
block varchar(5) Allow Null
sqyards numeric(5, 0) Allow Null
rate numeric(18, 0) Allow Null
plot_total_rate numeric(18, 0) Allow Null
Book_amt numeric(18, 0) Allow Null
date datetime Allow Null
referance varchar(50) Allow Null
status varchar(15) Allow Null
,i made a form plotmaster in visual basic related to the respected table field, the referance feild has combo box property where the refarance name will automatically add from agent master, which occcurs already successfully at the time of form load of plot master.i used a goup box where three radio button appear, 1-booked,2-hold,3-fresh, when user click on the respected radio button the same radiobutton text like(booked, hod, refresh) will store in status field.
here is the coding.
Imports System.Data.SqlClient
Public Class frmplot
Dim cnn As New SqlConnection("Data Source=toshiba-pc;Initial Catalog=VRINDAVAN;User ID=sa;password=zion123")
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
Dim da As SqlDataAdapter
Dim ds As New DataSet
Dim stable As DataTable
Dim sbuilder As SqlCommandBuilder
Private Sub frmplot_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
comboload()
txtplno.Focus()
dgvstatus2.[ReadOnly] = True
txtdt.Text = (Format(Now, "short date"))
cnn.Close()
End Sub
Private Sub comboload()
cnn.Open()
Dim strSQL As String = "SELECT * FROM agentmaster"
Dim da As New SqlDataAdapter(strSQL, cnn)
Dim ds As New DataSet
da.Fill(ds, "agentmaster")
With cmbref
.DataSource = ds.Tables("agentmaster")
.DisplayMember = "aname"
.ValueMember = "acode"
.SelectedIndex = 0
cnn.Close()
End With
End Sub
Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
dgvstatus2.[ReadOnly] = True
If txtplno.Text = "" Then
MsgBox("Please Enter Plot No.", MsgBoxStyle.OkOnly, "Plot Master")
txtplno.Focus()
ElseIf txtpsize.Text = "" Then
MsgBox("Please Enter Size of Plot", MsgBoxStyle.OkOnly, "Plot Master")
txtpsize.Focus()
ElseIf txtblock.Text = "" Then
MsgBox("You must Enter Block", MsgBoxStyle.OkOnly, "Agent Master")
txtblock.Focus()
ElseIf txtsyard.Text = "" Then
MsgBox("You must Enter Square Yard.", MsgBoxStyle.OkOnly, "Agent Master")
txtsyard.Focus()
ElseIf txtrate.Text = "" Then
MsgBox("You must Enter Rate.", MsgBoxStyle.OkOnly, "Agent Master")
txtrate.Focus()
ElseIf txtbamt.Text = "" Then
MsgBox("You must Enter Boking Amount", MsgBoxStyle.OkOnly, "Agent Master")
txtbamt.Focus()
Else
insert()
End If
End Sub
Private Sub insert()
txttpr.ReadOnly = True
Dim status As New GroupBox
Dim R, S As String
R = ""
If (cmbref.SelectedIndex > -1) Then
R = cmbref.Text.ToString
End If
With status
If rbuttonbook.Checked = True Then
S = rbuttonbook.Text
ElseIf rbuttonhld.Checked = True Then
S = rbuttonhld.Text
Else
S = "None"
End If
End With
cnn.Open()
cmd.CommandText = "insert into plotmaster (plotno,plotsize,block,sqyards,rate,plot_total_rate,Book_amt,date,referance,status) values ('" & txtplno.Text & "','" & txtpsize.Text & "','" & txtblock.Text & "','" & txtsyard.Text & "','" & txtrate.Text & "','" & txttpr.Text & "','" & txtbamt.Text & "',#" & txtdt.Text & "#,'" & R & "','" & S & "')"
cmd.ExecuteNonQuery()
cnn.Close()
MessageBox.Show("Data Saved Successfully", "Party Master")
txtplno.Text = ""
txtpsize.Text = ""
txtblock.Text = ""
txtsyard.Text = ""
txtrate.Text = ""
cmbref.ResetText()
txttpr.Text = ""
txtbamt.Text = ""
txtplno.Focus()
loadgrid()
End Sub
Private Sub loadgrid()
Dim sql As String = "select * from plotmaster"
Dim DataTab As New DataTable
cnn.Open()
cmd = New SqlCommand(sql, cnn)
da = New SqlDataAdapter(cmd)
sbuilder = New SqlCommandBuilder(da)
ds = New DataSet()
da.Fill(ds, "plotmaster")
stable = ds.Tables("plotmaster")
cnn.Close()
dgvstatus2.DataSource = ds.Tables("plotmaster")
'Dgvstatus1.ReadOnly = True
'Dgvstatus1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
dgvstatus2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
End Sub
Private Sub rbuttonhld_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbuttonhld.CheckedChanged
Dim S As String
If rbuttonhld.Checked = True Then
S = rbuttonhld.Text
Else
S = "None"
End If
End Sub
Private Sub rbuttonbook_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbuttonhld.Click
End Sub
Private Sub cmbref_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbref.SelectedIndexChanged
Dim R As String
R = ""
If (cmbref.SelectedIndex > -1) Then
R = cmbref.SelectedItem.ToString
End If
End Sub
Private Sub rbuttonhld_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbuttonhld.Click
End Sub
Private Sub rbuttonfresh_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbuttonfresh.CheckedChanged
Dim S As String
If rbuttonfresh.Checked = True Then
S = rbuttonfresh.Text
Else
S = "None"
End If
End Sub
Private Sub rbuttonfresh_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbuttonfresh.Click
End Sub
Private Sub txtrate_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtrate.LostFocus
Dim ra, t, sq As Integer
ra = Val(txtrate.Text)
sq = Val(txtsyard.Text)
t = ra * sq
txttpr.Text = t
End Sub
Private Sub rbuttonbook_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbuttonbook.CheckedChanged
Dim S As String
If rbuttonbook.Checked = True Then
S = rbuttonbook.Text
Else
S = "None"
End If
End Sub
End Class
when i run the program the eror comes :--ExecuteNonQuery: Connection property has not been initialized.
where is the problem , the same syntex of insert i am using in agent master it's working,
pls do needfull and send me the solution urgently,
regard's
Anand
|
|
|
|
|
Member 10192835 wrote: pls do needfull and send me the solution urgently, It's not urgent. We're volunteers, and reply in our own spare time. I can even choose not to reply.
You should assign the connection cnn to the Connection property of the SqlCommand. As is, it doesn't know on which connection to execute your nonquery.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|