Methods, apparatuses, electronic devices, and storage media for embedding files in documents.

By scanning and recording line numbers line by line in the document and automatically embedding the file using VBA scripts, the problem of low efficiency and low accuracy of file embedding in existing technologies is solved, and a highly efficient and accurate method for embedding files into documents is achieved.

CN115422886BActive Publication Date: 2026-03-13CHINA CONSTRUCTION BANK +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-13
Publication Date
2026-03-13

Smart Images

  • Figure CN115422886B_ABST
    Figure CN115422886B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, electronic device, and storage medium for embedding files in a document, belonging to the field of computer technology. The method includes acquiring a target document; scanning the target document line by line; recording the line number of the target document when a tag is scanned; reading the string content of the identifier information when the line number is scanned; obtaining the file path information corresponding to the string content according to a preset correspondence between the string content and file path information, wherein the string content is information about the embedded file, and the file path information includes the type of the embedded file; acquiring a VBA script corresponding to the type of the embedded file; configuring the file path information and the name of the embedded file as parameters of the VBA script; and running the VBA script to embed the embedded file at the line number position of the target document. Using the method for embedding files in a document provided in this application improves the efficiency of embedding a large number of files and ensures the accuracy of file embedding.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more specifically to a method, apparatus, electronic device, and computer-readable storage medium for embedding files in a document. Background Technology

[0002] When reviewing documents at work and needing to refer to other files, relevant reference files are inserted into the document.

[0003] This method of inserting reference files into a target document involves selecting a specific location within the target document, browsing the file's local address, and choosing the desired file to insert. However, this method is unsuitable for inserting a large number of files. Because the local addresses of each file are inconsistent, it's necessary to locate the local address of each file and insert it into the target document. This file insertion process is repetitive, inefficient, and makes it difficult to guarantee the accuracy of file embedding. Summary of the Invention

[0004] This application provides a method, apparatus, electronic device, and computer-readable storage medium for embedding files, which can solve the problem of embedding a large number of files into documents, improve the efficiency of embedding files into target documents, and ensure the accuracy of embedding files into documents.

[0005] In a first aspect, embodiments of this application provide a method for embedding a file in a document, the method comprising:

[0006] Obtain the target document;

[0007] Scan the target document line by line;

[0008] Record the line number of the target document when a tag is detected;

[0009] When the row number identification information is detected, read the string content of the identification information;

[0010] Based on the preset correspondence between string content and file path information, obtain the file path information corresponding to the string content. The string content is the information of the embedded file, and the file path information is the file path information of the embedded file, including the type of the embedded file.

[0011] Retrieve the VBA script corresponding to the type of the embedded file; configure the file path information and the name of the embedded file as parameters of the VBA script;

[0012] Run a VBA script to embed the file at the line number position in the target document.

[0013] In one possible implementation, the method of embedding a file in a document further includes:

[0014] When the file path information of the target embedded file changes, obtain the target file path information after the change.

[0015] Modify the file path information corresponding to the string content of the target embedded file in the correspondence to the target file path information.

[0016] In one possible implementation, the method of embedding a file in a document further includes:

[0017] In response to the user's input to view the target embedded file, the file path information of the target embedded file is retrieved from the preset correspondence between string content and file path information based on the string content of the target embedded file;

[0018] Retrieve the target embedded file from the location corresponding to the file path information.

[0019] In one possible implementation, scanning the target document line by line includes:

[0020] Split the target document into multiple documents according to the chronological order of its content;

[0021] Multiple documents are scanned line by line.

[0022] In one possible implementation, the method further includes:

[0023] Multiple documents are merged after embedding, following the order of the target document content.

[0024] In one possible implementation, the type of the embedded file includes xlsx, pdf, doc, or docx.

[0025] Secondly, embodiments of this application provide an apparatus for embedding a file in a document. The apparatus for embedding a file includes an acquisition module for acquiring a target document.

[0026] The scanning module is used to record the line number of the target document when a tag is detected.

[0027] The reading module is used to read the string content of the identification information when the row number identification information is scanned;

[0028] The acquisition module is also used to acquire the file path information corresponding to the string content according to the preset correspondence between string content and file path information. The string content is the information of the embedded file, and the file path information is the file path information of the embedded file, including the type of the embedded file.

[0029] The acquisition module is also used to acquire the VBA script corresponding to the type of the embedded file;

[0030] The configuration module is used to configure file path information and the name of the embedded file as parameters for the VBA script;

[0031] The run module is used to run VBA scripts to embed the embedded file at the line number position in the target document.

[0032] Thirdly, embodiments of this application provide an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the above-mentioned file embedding method.

[0033] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the various processes of the above-described file embedding embodiments.

[0034] Fifthly, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electronic device, cause the electronic device to perform the various processes described above for embedding files in a document.

[0035] The method, apparatus, electronic device, computer-readable storage medium, and computer program product for embedding files in a document provided in this application embodiment involve: acquiring a target document; scanning the target document line by line; recording the line number of the target document when a tag is scanned; reading the string content of the identifier information when the line number identifier information is scanned; obtaining the file path information corresponding to the string content according to a preset correspondence between the string content and file path information, where the string content is the information of the embedded file and the file path information is the file path information of the embedded file, including the type of the embedded file; obtaining a VBA script corresponding to the type of the embedded file; configuring the file path information and the name of the embedded file as parameters of the VBA script; and running the VBA script to embed the embedded file at the line number position of the target document. Therefore, when multiple files need to be embedded in a document, only the file path information and the name of the embedded file need to be configured as parameters of the VBA script, and the VBA script needs to be run to embed the embedded files into the target document. This eliminates the need to browse the local address of the file to select and insert the file into the target document, thus achieving the purpose of embedding a large number of files into a document, improving work efficiency. At the same time, running the script program to complete a large number of file embeddings can avoid human error and ensure the accuracy of file embedding in the document. Attached Figure Description

[0036] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application are briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0037] Figure 1 A flowchart illustrating a method for embedding a file in a document, as provided in this application embodiment;

[0038] Figure 2 A structural block diagram of a method for embedding files in a document, provided in an embodiment of this application;

[0039] Figure 3 This is a structural diagram of an electronic device for an embodiment of the present application that provides a method for embedding files in a document. Detailed Implementation

[0040] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.

[0041] In this document, relational terms such as "first," "second," etc., are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.

[0042] It should be noted that the acquisition, storage, use, and processing of data in this application embodiment all comply with the relevant provisions of national laws and regulations.

[0043] With the rise of electronic documents, when users need to refer to files related to the document content while creating or viewing the document, they often insert several files related to the document content at a certain location for easy reference.

[0044] For example, in the process of creating a document, embedding files into a target document allows for the sharing of multiple files within a single target document. Compared to traditional file embedding methods, this method can quickly embed multiple files, overcoming the limitation on the number of files that can be inserted, improving work efficiency, avoiding errors caused by manual file embedding operations, and ensuring the accuracy of file embedding.

[0045] The applicant's research has revealed the following technical problems with the current method of embedding files in a document: Since the local addresses of each file are inconsistent, the process of inserting a file requires browsing the local addresses of each file and embedding the file from the local address into the target document. This process of embedding a file into the target document is repetitive and greatly reduces the user's operating experience. The manual operation of embedding multiple files is inefficient and it is difficult to guarantee the accuracy of file embedding.

[0046] In view of the above research findings, embodiments of this application provide a method for embedding files in a document to solve the aforementioned technical problems existing in the prior art.

[0047] The technical concept of this application embodiment is as follows: when a large number of files need to be inserted, the identification information in the target document is read to obtain the string content. The file path information is obtained through the correspondence between the string content and the file path information. The VBA script corresponding to the file type is obtained. The file path information and file name are used as VBA script parameters. Only the VBA script needs to be run to complete the corresponding position of the file embedded in the document. There is no need to find the local address of each file. The files are inserted into the specified position in the document in batches and by address, thereby achieving the purpose of embedding a large number of files into the document, improving work efficiency, and ensuring the accuracy of file embedding in the document.

[0048] This embodiment provides a method for embedding files in a document, such as... Figure 1 As shown, the steps are as follows:

[0049] S101: Obtain the target document.

[0050] The target document is the document to be embedded in. In one embodiment, the target document can be an electronic document in any readable format.

[0051] S102: Perform line-by-line scanning of the target document.

[0052] The target document contains multiple lines, and the lines in the file to be embedded contain tags to facilitate scanning and tag recognition.

[0053] In this embodiment of the application, tags are identified by scanning the target document line by line.

[0054] S103: Record the line number of the target document when a tag is detected.

[0055] Line numbers indicate the location of the file to be embedded. When tags are found in the target document, the line number of the target document is recorded, which indicates the location of the file to be embedded.

[0056] S104: When the row number identification information is scanned, read the string content of the identification information.

[0057] Each identifier contains a string, which represents the position where the document is embedded in the target document. For example, each string contains a number n, which represents the nth position where the document is embedded in the target document.

[0058] S105: Obtain the file path information corresponding to the string content based on the preset correspondence between string content and file path information.

[0059] The string content contains information about the embedded file, and the file path information is the file path information of the embedded file, which includes the type of the embedded file.

[0060] In some embodiments, before obtaining the file path information corresponding to the string content based on the preset correspondence between string content and file path information, the method includes constructing the preset correspondence between string content and file path information. The specific process of constructing the correspondence is as follows: obtain the path information of the embedded file, and construct the correspondence between the string content and file path information based on the string content corresponding to the position of the embedded file in the target document, and record and store the correspondence.

[0061] In some embodiments, the correspondence may be presented as a correspondence table.

[0062] The correspondence between file path information and string content is a mapping relationship, that is, one string content can correspond to one file path information, and one file path information can correspond to multiple string contents.

[0063] The string content contains information about the embedded file, including its location within the target file. In some embodiments, the embedded file information may also include information about which file the embedded file is embedded in within the target document.

[0064] In this embodiment of the application, by using the preset correspondence between strings and file path information, when obtaining the embedding file of the target document to be embedded, the string content is read, and the file path information corresponding to the embedding file can be obtained conveniently and quickly.

[0065] S106: Retrieve the VBA script corresponding to the type of the embedded file; configure the file path information and the name of the embedded file as parameters of the VBA script.

[0066] VBA (Visual Basic for Applications) is a macro language used to perform automated tasks in desktop applications. It is considered a highly stable language among Microsoft's official languages.

[0067] In some embodiments, Python is used to call a VBA script corresponding to the file type of the target embedded file, and the file path information and file name are configured as parameters of the VBA script. In this way, by running the VBA script, the file at the local address is obtained, and the process of embedding the file into the target document is completed efficiently and quickly.

[0068] In one example, suppose we need to embed a file at the position of the line {model_validate_result_insert_location_1}. First, we need to record a VBA script that replaces the tag information to embed the xlsx file. When the file path information of the embedded file changes, we need to modify Sub insertXlsx() to Sub insertXlsx(FilePath as String, FileName as String), and change FileName_:="D:\myfile\1.xlsx" to FileName_:=FilePath. This will give us a VBA script that passes parameters.

[0069] S107: Run the VBA script to embed the file at the line number position of the target document.

[0070] This application embodiment utilizes a VBA script corresponding to the file type of the embedded file to embed the file into the line number of the target document. By using VBA script to implement file embedding, the required line number position of the file can be quickly located, so as to quickly complete the task of embedding multiple embedded files, improve the user experience, and increase the efficiency of file embedding.

[0071] The method for embedding files in a document provided in this application embodiment allows for the embedding of multiple files into a document. When multiple files need to be embedded, the file path information and the name of the embedded file are configured as parameters for the VBA script. Running the VBA script will embed the embedded files into the target document, eliminating the need to browse the local address of the embedded file to select and insert it into the target document. This achieves the goal of embedding a large number of files into a document, improving work efficiency. At the same time, running the script to complete the embedding of a large number of files can avoid human error and ensure the accuracy of file embedding into the document.

[0072] In some embodiments, when the file path information of the target embedded file changes, the target file path information after the change is obtained. The file path information corresponding to the string content of the target embedded file in the correspondence is modified to the target file path information.

[0073] When the file path information changes, the target file path information after the change is obtained. This is then achieved by modifying the path information corresponding to the string in the file configuration table to the changed target file path information. Here, the target embedded file specifically refers to a file within the embedded files.

[0074] In a specific example, a file configuration table is generated based on the mapping between string content and file path information. If the path information of the target embedded file in the file configuration table is C:\Program Files\t.xlsx, and the file is now moved to C:\Windows\t.xlsx, it cannot be found in C:\Program Files\t.xlsx. Therefore, to ensure the smooth embedding of the target embedded file into the target document, this file configuration table needs to be maintained. The file path information corresponding to the string content of the target embedded file in the file configuration table needs to be modified to C:\Windows\t.xlsx. This will successfully embed the target embedded file C:\Windows\t.xlsx into the target document, where xlsx is the file type of the target embedded file, and t indicates that the embedded file is located in the t-th folder within the local address C:\Windows.

[0075] For example, a string {model_validate_result_insert_location_n} is preset in the Flag column, corresponding to a file path information D:\myfile\t.xlsx in the File column. Each line of information describes a string and a file path. The file path information ends with ".xlsx" to indicate the file type of the target document to be embedded. When calling a VBA script file, the type of VBA script to be called can be determined based on the description in the file path information, thereby improving the efficiency of embedding files and documents.

[0076] Before embedding files, a string of information for the embedding file is first preset, such as the string `{model_validate_result_insert_location_n}`, where `n` (a number) represents the nth position in the target document where the embedding file will be placed. The string content of the embedding file corresponds to the corresponding file path information. During work or study, multiple embedding files may be moved to another folder, causing the file configuration table to become invalid. This means the string content will no longer correspond to the changed file path information, resulting in the VBA script failing to find the file and the program failing to run. Therefore, when the file path information of the embedding file changes, the file path information corresponding to the string content of the embedding file in the file configuration table needs to be modified to ensure that the file configuration table remains valid, meaning the string content and its corresponding file path information are effective. This allows the VBA script to run smoothly and successfully embed multiple embedding files into the specified positions in the target document. By modifying the file path information corresponding to the string content in the file configuration table of multiple embedded files, the process of embedding multiple embedded files into the target document can be completed simply by running a VBA script. It is no longer necessary to browse the file path information, find the location of the embedded files, select the embedded files, and embed them into the target document. This method can efficiently and quickly embed multiple embedded files with changed path information into the target document, improving the efficiency and accuracy of file embedding.

[0077] In some embodiments, the method of embedding a file in a document may further include:

[0078] In response to the user's input to view the target embedded file, the file path information of the target embedded file is retrieved from the preset correspondence between string content and file path information, based on the string content of the target embedded file.

[0079] The target embedded file is retrieved from the location corresponding to the file path information. When a user wants to know the file path information of the target embedded file, or performs a viewing input operation for the target embedded document, the device reads the string content of the identification information when it receives the user's input to view the target embedded document. It can find the file by searching the preset correspondence between the string content and the file path information. In this way, by maintaining the correspondence between the string and the file path information, the file can be easily found.

[0080] In some embodiments, the method of embedding files in a target document by scanning the target document line by line includes: splitting the target document into multiple documents according to the order of the content of the target document; and scanning the multiple documents line by line respectively.

[0081] When dealing with a large amount of document content, to avoid slow scanning efficiency of the target document, the document can be split sequentially before scanning. After embedding the target document into the file, the target document can be merged sequentially to improve the efficiency of document scanning and embedding, thus saving time.

[0082] In some embodiments, the method of embedding files in a document may further include: merging multiple documents after embedding the files according to the order of the content of the target document.

[0083] After embedding the split target document, the multiple split documents are merged into one document according to the order of the document content. This facilitates the subsequent sharing of the target document with embedded files, allowing you to obtain multiple shareable files while obtaining one target document, thus improving the efficiency of file sharing and enhancing the user experience.

[0084] In some embodiments, the type of the embedded file may include xlsx, pdf, doc, or docx. Different embedded file types correspond to different VBA script files. When it is necessary to embed a file of a target file type into a document, the VBA script file corresponding to the target file type is called and run to embed the target file type file.

[0085] In one example, during the process of embedding a document, if the file type is pdf, then the VBA file corresponding to the pdf file type is called to complete the embedding of the pdf file.

[0086] This application embodiment improves the diversity of file embedding types and further enhances the efficiency of file embedding by setting up VBA script files corresponding to different file types.

[0087] In addition, see Figure 2 This application also provides an apparatus 200 for embedding files in a document. The apparatus 200 includes an acquisition module 201, a scanning module 202, a reading module 203, a configuration module 204, and an execution module 205. These modules work together to complete the process of embedding the file into the target document, specifically:

[0088] Module 201 is used to retrieve the target document.

[0089] The scanning module 202 is used to record the line number of the target document when a tag is scanned.

[0090] The reading module 203 is used to read the string content of the identification information when the row number identification information is scanned.

[0091] The acquisition module 201 is also used to acquire the file path information corresponding to the string content according to the preset correspondence between string content and file path information. The string content is the information of the embedded file, and the file path information is the file path information of the embedded file, including the type of the embedded file.

[0092] The acquisition module 201 is also used to acquire the VBA script corresponding to the type of the embedded file.

[0093] Configuration module 204 is used to configure file path information and the name of the embedded file as parameters for the VBA script.

[0094] Module 205 is used to run VBA scripts to embed the embedded file at the line number position of the target document.

[0095] In some embodiments, the device may further include a modification module.

[0096] The acquisition module is also used to acquire the target file path information after the target embedded file changes when the file path information of the target embedded file changes.

[0097] The modification module is used to modify the file path information corresponding to the string content of the target embedded file in the correspondence to the target file path information.

[0098] In some embodiments, the apparatus may further include:

[0099] The query module is used to respond to the user's input to view the target embedded file. Based on the string content of the target embedded file, it queries the file path information of the target embedded file from the preset correspondence between string content and file path information.

[0100] The acquisition module is also used to retrieve the target embedded file from the location corresponding to the file path information.

[0101] In some embodiments, the apparatus further includes a splitting module, wherein the scanning module scans the target document line by line, including:

[0102] The splitting module is used to split a target document into multiple documents according to the order of its content.

[0103] The scanning module is used to scan multiple documents line by line.

[0104] In some embodiments, the apparatus further includes a merging module for merging multiple documents after file embedding according to the order of the target document content.

[0105] In some embodiments, the type of the embedded file includes xlsx, pdf, doc, or docx.

[0106] The various modules of the apparatus for embedding files in a document provided in the embodiments of this application can achieve... Figure 1 This document provides the functionality for each step of embedding files in a document, and achieves the corresponding technical effects. For the sake of brevity, these steps will not be elaborated upon here.

[0107] This application also provides an electronic device, such as... Figure 3 As shown, the electronic device 300 may include: a processor 301, a memory 302, a communication interface 303, and a bus 310.

[0108] Specifically, the processor 301 may include a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits that can be configured according to the embodiments of the present application.

[0109] Memory 302 may include mass storage for data or instructions. For example, and not limitingly, memory 302 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. In one embodiment, memory 302 may include removable or non-removable (or fixed) media, or memory 302 may be non-volatile solid-state memory. Memory 302 may be internal or external to the integrated gateway housing device.

[0110] In one embodiment, memory 302 may be read-only memory (ROM). In one embodiment, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these.

[0111] Storage 302 may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, electrical, optical, or other physical / tangible memory storage devices. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this disclosure.

[0112] The processor 301 reads and executes computer program instructions stored in the memory 302 to achieve... Figure 1 The methods S101 to S107 in the illustrated embodiment achieve the following: Figure 1 The embodiments shown achieve the corresponding technical effects by performing their methods / steps, which will not be elaborated here for the sake of brevity.

[0113] In one example, the electronic device 300 may also include a communication interface 303 and a bus 310. For example, Figure 3 As shown, the processor 301, memory 302, and communication interface 303 are connected through bus 310 and complete communication with each other.

[0114] The communication interface 303 is mainly used to realize communication between various modules, devices, units and equipment in the embodiments of the present invention.

[0115] Bus 310 includes hardware, software, or both, that couples together components of an electronic device that embeds files in a document. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, a Wireless Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable single buses or combinations of two or more of these. Where appropriate, bus 310 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, this application contemplates any suitable bus or interconnect.

[0116] The electronic device can execute the method for embedding files in a document as described in this application embodiment based on a VBA script corresponding to the embedded file type, thereby achieving a combination of... Figure 1 and Figure 2 The methods and apparatus described herein are for embedding files in a document.

[0117] Furthermore, in conjunction with the methods for embedding files in documents as described in the above embodiments, this application embodiment can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; these computer program instructions are executed by a processor using any of the methods for embedding files in documents as described in the above embodiments.

[0118] This application also provides a computer program product in which instructions, when executed by a processor of an electronic device, cause the electronic device to perform various processes implementing any of the above-described methods for embedding files in a document.

[0119] This application, employing the above technical solution, provides a method, apparatus, electronic device, computer-readable storage medium, and computer program product for embedding files in a document. It involves acquiring a target document, scanning it line by line, recording line numbers when tags are detected, reading the string content of the line number identifier when the identifier is detected, and obtaining the corresponding file path information based on a preset correspondence between the string content and file path information. The string content represents the embedded file information, including the type of the embedded file and the file path information. A VBA script corresponding to the type of the embedded file is obtained. The file path information and the name of the embedded file are configured as parameters for the VBA script, and the VBA script is run to embed the file at the line number position in the target document. File embedding is frequently required in daily office software use, but manually handling a large number of files is time-consuming. This invention, using the above technical solution, can achieve batch file embedding in documents. For different types of files, a VBA script file corresponding to the file type can be called, improving embedding efficiency while ensuring stability. This invention avoids complex manual processing when embedding files into a document, thus achieving the goal of embedding a large number of files into a target document.

[0120] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of the present invention.

[0121] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this invention are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, read-only memory (ROM), flash memory, erasable read-only memory (EROM), floppy disks, compact disc read-only memory (CD-ROM), optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.

[0122] It should also be noted that the exemplary embodiments mentioned in this invention describe methods or systems based on a series of steps or apparatus. However, this invention is not limited to the order of the steps described above; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

[0123] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), electronic devices, and storage media according to embodiments of this application. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to create a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.

[0124] The above description is merely a specific embodiment of the present invention. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the protection scope of the present invention.

Claims

1. A method for embedding a file in a document, characterized in that, The method includes: Obtain the target document; The target document is scanned line by line; Record the line number of the target document when a tag is detected; When the identification information of the row number is detected, the string content of the identification information is read; Based on the preset correspondence between string content and file path information, the file path information corresponding to the string content is obtained, wherein the string content is the information of the embedded file, the file path information is the file path information of the embedded file, and the file path information includes the type of the embedded file; Obtain the VBA script corresponding to the type of the embedded file; configure the file path information and the name of the embedded file as parameters of the VBA script; Run the VBA script to embed the embedded file at the line number position in the target document.

2. The method for embedding a file in a document according to claim 1, characterized in that, The method further includes: When the file path information of the target embedded file changes, obtain the target file path information after the change; Modify the file path information corresponding to the string content of the target embedded file in the correspondence to the target file path information.

3. The method for embedding a file in a document according to claim 1, characterized in that, The method further includes: In response to the user's input to view the target embedded file, the file path information of the target embedded file is queried from the preset correspondence between the string content and the file path information, based on the string content of the target embedded file; The target embedded file is obtained from the location corresponding to the file path information.

4. The method for embedding a file in a document according to claim 1, characterized in that, The step of scanning the target document line by line includes: The target document is split into multiple documents according to the chronological order of its content; The documents are scanned line by line.

5. The method for embedding a file in a document according to claim 4, characterized in that, The method further includes: The multiple documents are merged after file embedding according to the order of the target document content.

6. The method for embedding a file in a document according to any one of claims 1 to 5, characterized in that, The embedded file type includes xlsx, pdf, doc, or docx.

7. An apparatus for embedding files in a document, characterized in that, The device includes: The acquisition module is used to acquire the target document; The scanning module is used to record the line number of the target document when a tag is detected. The reading module is used to read the string content of the identification information when the identification information of the row number is scanned; The acquisition module is further configured to acquire the file path information corresponding to the string content according to the preset correspondence between string content and file path information, wherein the string content is the information of the embedded file, the file path information is the file path information of the embedded file, and the file path information includes the type of the embedded file; The acquisition module is also used to acquire the VBA script corresponding to the type of the embedded file; A configuration module is used to configure the file path information and the name of the embedded file as parameters of the VBA script; The execution module is used to run the VBA script to embed the embedded file at the line number position of the target document.

8. An electronic device, the device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it performs the method of embedding a file in a document as described in any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of embedding a file in a document as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, When the instructions in the computer program product are executed by the processor of the electronic device, the electronic device causes the electronic device to perform the method of embedding a file in a document as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Malicious document detection method, device and system based on attribute domain abnormal call

    CN110765455A

  • Nested document extraction method and device, electronic equipment and storage medium

    CN111488556A