Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   Realm Works Discussion (http://forums.wolflair.com/forumdisplay.php?f=67)
-   -   Help: PDF to XLSX Tool (http://forums.wolflair.com/showthread.php?t=62157)

daplunk February 22nd, 2019 03:38 PM

Help: PDF to XLSX Tool
 
Hi Team,

Hoping there are some Excel gurus amongst us who may we able to assist.

I'm creating a macro enabled Excel file that allows you to paste a monster stat-block into it. It rips the paste apart applying all the formatting requirements in line with a standard 5e stat-block and then copies the text into a table.

The intention is that table would then be loaded into the CSV to RW Import Tool. I'm basically trying to make it as efficient as possible to get monsters from a PDF into RW fully formatted.

And I'm close. I have it all working except the final step where I need to copy the formatted cells into a table.

I can copy the values and I've got it working so that it will copy the text in as BOLD.

The challenge I've yet to overcome however is pasting the data in where a single cell contains BOLD, ITALICS and NORMAL text. Monster Attacks obviously have this type of formatting.

Here's the file in case anyone knows the answer. Once done this will be something I upload for the community.

https://drive.google.com/file/d/1gUM...ew?usp=sharing

1. Paste monster stat-block from PDF (note, need to move text to correct lines)
2. Press the button
3. Monster stat-block is converted into format compatible with the CSV to RW Importer
https://i.imgur.com/9Z3Z1VX.png

This is where it's going wrong. As you can see I have the formatting working in the Actions 1 cell at the top. This line is then copied into the next available line on the table. It's applying BOLD to the whole line instead of copying the formatting from the source cell.

https://i.imgur.com/NXeuThS.png

Dakadin February 22nd, 2019 05:48 PM

Try using something like this:
Code:

ThisWorkbook.Worksheets("Sheet1").Range("B1").Copy Destination:=ThisWorkbook.Worksheets("Sheet1").Range("A1")

daplunk February 22nd, 2019 07:28 PM

That's the answer although its not the complete answer!

Copying like that simply replicates the excel copy function. Thus is copies the formulas. So it doesn't work on most of it. It does work on the bits I'm having trouble with. So now I just need to create two separate parts of the copy process.

One for this bit and then a different one for the bits that dont have formatting but have formulas.

Thank you!

Ash Nazg February 27th, 2019 08:11 PM

To preserve the multiple text formatting in the cell, you need to use the PasteSpecial method of the destination Range object, and you need to use the xlPasteAllUsingSourceTheme XLPasteType.

Code:

mySourceRange.Copy
myDestinationRange.PasteSpecial Paste:=xlPasteAllUsingSourceTheme

I hope that helps,
~ Ash


All times are GMT -8. The time now is 09:09 PM.

Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.