在vba中
Sub EditPaste()
MsgBox "EditPaste"
End Sub
这样就能重写office的粘贴动作了。当用菜单项,图标按钮,键盘快捷键都能响应。
请问各位:如果在vc这能不能实现呢?或者将这段代码如何转换成vc的,谢谢大家了。 已经被office的粘贴折麽n久了。
Sub EditPaste()
MsgBox "EditPaste"
End Sub
这样就能重写office的粘贴动作了。当用菜单项,图标按钮,键盘快捷键都能响应。
请问各位:如果在vc这能不能实现呢?或者将这段代码如何转换成vc的,谢谢大家了。 已经被office的粘贴折麽n久了。
其中粘贴时 Selection.Paste
修改剪贴板的内容,可以使用OpenClipboard打开,使用GetClipboardData读取数据进行修改,使用CloseClipboard关闭。单纯将你那段代码改成vc的就是:
void EditPaste()
{
AfxMessageBox("EditPaste");
}
呵呵,开玩笑
其中一个方法是打开剪切板,将数据输入剪切板,执行其他的操作,最后还要关闭剪切板。
拜托了。
Word.ApplicationClass wordApp = new Word.ApplicationClass();
Word.DocumentClass myDoc;
object oMissing = System.Reflection.Missing.Value;
string path = Server.MapPath(Request.ApplicationPath);
path = path + "\\user\\upload\\template.dot";
object template = @path;
wordApp.Documents.Add(ref template, ref oMissing, ref oMissing, ref oMissing); myDoc = (Word.DocumentClass)wordApp.ActiveDocument;
wordApp.Visible = false;
object missing = Type.Missing;
wordApp.Selection.Find.Replacement.Text = "";
wordApp.Options.ReplaceSelection = true;
wordApp.Selection.Find.Format = true;
wordApp.Selection.Find.Wrap = Word.WdFindWrap.wdFindContinue;
wordApp.Selection.Find.Format = false;
wordApp.Selection.Find.MatchCase = false;
wordApp.Selection.Find.MatchWholeWord = false;
wordApp.Selection.Find.MatchByte = true;
wordApp.Selection.Find.MatchWildcards = false;
wordApp.Selection.Find.MatchSoundsLike = false;
wordApp.Selection.Find.MatchAllWordForms = false;
for (int i = 1; i < 10; i++)
{
string findtext = "**" + i.ToString();
object replaceAll = Word.WdReplace.wdReplaceAll;
wordApp.Application.Selection.Find.ClearFormatting();
wordApp.Selection.Find.Text = findtext;
wordApp.Selection.Find.Replacement.ClearFormatting();
string lab = "label" + i.ToString();
Label tem = (Label)this.MyDataList.Items[0].FindControl(lab);
string tempt = tem.Text;
if (i == 2)
{
tempt = ((Label)this.MyDataList.Items[0].FindControl("label1")).Text + "(" + tem.Text + ")";
}
string replacetext = tempt.Replace("<br/>", "");
wordApp.Selection.Find.Execute(
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing);
wordApp.Selection.TypeText(replacetext);
}
myDoc.SaveAs(ref fileName, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
object missingValue = Type.Missing;
object doNotSaveChanges = Word.WdSaveOptions.wdDoNotSaveChanges; myDoc.Close(ref doNotSaveChanges, ref missingValue, ref missingValue);
wordApp.Quit(ref missingValue, ref missingValue, ref missingValue);
}
上面包含了打开一个Word模板,查找,粘贴,关闭等功能
我正是因为不想让粘贴的时候走剪贴板,想让去访问我自己可控的一段内存区,所以才要重写粘贴啊。
要么就是将每个粘贴途径都重写,但是似乎都不容易啊。