VBA的新手,请多多包涵。我想创建一个Excel VBA代码,要求用户打开带有文本表单域的预先存在的Word文档,并在这些表单域中输入现有的Excel数据。我目前有将Excel数据写入Word文本表单字段的代码,但是由于将abstract class GeneratorForAnnotatedField<AnnotationType> extends Generator {
/// Returns the annotation of type [AnnotationType] of the given [element],
/// or [null] if it doesn't have any.
DartObject getAnnotation(Element element) {
final annotations =
TypeChecker.fromRuntime(AnnotationType).annotationsOf(element);
if (annotations.isEmpty) {
return null;
}
if (annotations.length > 1) {
throw Exception(
"You tried to add multiple @$AnnotationType() annotations to the "
"same element (${element.name}), but that's not possible.");
}
return annotations.single;
}
@override
String generate(LibraryReader library, BuildStep buildStep) {
final values = <String>{};
for (final element in library.allElements) {
if (element is ClassElement && !element.isEnum) {
for (final field in element.fields) {
final annotation = getAnnotation(field);
if (annotation != null) {
values.add(generateForAnnotatedField(
field,
ConstantReader(annotation),
));
}
}
}
}
return values.join('\n\n');
}
String generateForAnnotatedField(
FieldElement field, ConstantReader annotation);
}
行转换为对话框而迷失了方向。任何帮助将不胜感激。
谢谢。
Set wd= wdApp.Documents.Open("FilePath")
答案 0 :(得分:0)
是否要用户输入Word文件的名称?您是否需要InputBox方法?
Dim strWord As String
strWord = InputBox(prompt:="Type the file path and name of the Word file.", title:="Which file?", default:="C:\Path\File.docx")
Set wd = wdApp.Documents.Open(strWord)
如果我不明白您的问题,请告诉我。