+ Reply to Thread
Results 1 to 19 of 19

RunTIme Error 4248

  1. #1
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    RunTIme Error 4248

    Hello everyone,

    I have previously posted this in this forum. http://www.mrexcel.com/forum/excel-q...ml#post3516111
    My bad for not following rules before posting. Thanks to someone for letting me read the rule but that has hit me that the pressure of my problem, I forgot for a while. I thought that my respect for others had been gone for a while.


    Basically, I hope someone can help me figure out this problem I have in Excel.

    I have this code that works fine to open ms word when I will paste data from excel. it also sets to the right position in word.
    Please Login or Register  to view this content.

    Then this code will do the copying from excel to word.
    Please Login or Register  to view this content.
    It works perfectly fine in my pc. up to now it's all ok. but when running from my colleagues pc, it seems to miss the active document. The open ms word is working in the other pc. but the pasting part which is the second code gives us the run time error 4248 as if there is no open document. but it has succesfully opened. not sure why my code is not detecting the open word doc. and why this happens only in the other pc.

    thanks in advance for the help.

    Jhun
    Last edited by excelaverage; 07-10-2013 at 06:24 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: RunTIme Error 4248

    Why 2 separate subs?
    Please Login or Register  to view this content.
    PS Can you please use code tags when posting code?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: RunTIme Error 4248

    Thanks Norie. I will try that one.

    I can't combine my two macros as the second macro its not consistent. The range differs depending on value.
    this part is Range("F3:J13").Copy is a 4 row data. sometimes it's 5, 6,7 or 8. so i use different code for them. I am not good in VB actually. My codes are mostly part by part then i just call them in single macro if I need them in sequence.

    Thanks really. I will try if this will work.

    Jhun

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: RunTIme Error 4248

    Jhun

    I can't see why that would stop you combining the subs.

    Just add code to either take user input for the no of rows to copy or to calculate the no of rows.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: RunTIme Error 4248

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  6. #6
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: RunTIme Error 4248

    I dont know how i make my code to do in such a way that it will copy 4 rows if only 4 of them have data. 5. 6 7, and 8 accordingly. So what i did, I made different macros and then put them in 4 different buttons. The button show/hide depending on number of rows.

  7. #7
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: RunTIme Error 4248

    I feel bad about this. I am so sorry. I am in panicking about this one. I should have read the rules again. I thought the other forum site is different from this one.

  8. #8
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: RunTIme Error 4248

    Hi Norie.

    I hope I did it right this time...

    thanks very much for the reminder...

  9. #9
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: RunTIme Error 4248

    Sir...
    I have edited my original post. Let me know if this should be ok

    thanks again

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: RunTIme Error 4248

    Jhun

    The forums aren't connected but both have a similar rule about cross-posting.

    By the way, one reason not to cross post is because it confuses things for everybody, including yourself.

    Anyway, back to the question.

    It should be straightforward to add to the code to copy the correct range and run it from one button.

    How is the no of rows/columns to copy determined?
    Last edited by Norie; 07-10-2013 at 02:05 PM.

  11. #11
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: RunTIme Error 4248

    I perfectly understand the upsetting part when cross posting.

    Norie,
    I have two tables.
    one has the main item and I always include in copying. thats range F11:J13. F11 is header
    then another table is at Capture.JPG

    then another table at range F14:J18. F14 and f15 are both header too.

    I put a formula in cell F20 to count the value in cell F16:F18.
    If it's 0, then it will copy only the main table and leaving the second one.

    if it's 1, then it copy main table down to the first row of the second table. so that's actually. F11:J16
    if it's 2, then F11:J17
    and 3, then F11:J18.

    That is why i just assigned 4 buttons then i will click the one depending on number of rows to copy or 0 for the main table only.

    I am glad if that can be merged into one macro only. but more than that. I am not clear why my macro is not working in other pc.

    in my end, it opens the word then does the copying.
    But in the other pc, it only opens the word doc but not the copying part. It gives the run time error 4288. as if the doc is not open...

    Thanks much sir...

  12. #12
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: RunTIme Error 4248

    I perfectly understand the upsetting part when cross posting.

    Norie,
    I have two tables.
    one has the main item and I always include in copying. thats range F11:J13. F11 is header
    then another table is at Attachment 249288

    then another table at range F14:J18. F14 and f15 are both header too.

    I put a formula in cell F20 to count the value in cell F16:F18.
    If it's 0, then it will copy only the main table and leaving the second one.

    if it's 1, then it copy main table down to the first row of the second table. so that's actually. F11:J16
    if it's 2, then F11:J17
    and 3, then F11:J18.

    That is why i just assigned 4 buttons then i will click the one depending on number of rows to copy or 0 for the main table only.

    I am glad if that can be merged into one macro only. but more than that. I am not clear why my macro is not working in other pc.

    in my end, it opens the word then does the copying.
    But in the other pc, it only opens the word doc but not the copying part. It gives the run time error 4248. as if the doc is not open...

    by the way the error points to this part of code.
    Please Login or Register  to view this content.
    Thanks much sir...
    Last edited by excelaverage; 07-10-2013 at 02:09 PM.

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: RunTIme Error 4248

    There could be a number of reasons that the 2nd code isn't working.

    I'd probably go for Word not actually being open when it runs.

    As for deciding what to copy, that is straightforward if you have things set up as you describe.
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: RunTIme Error 4248

    how do I do that? I am ok with Word not being opened but pasting is actually happening. is that what you meant Norie? Then I will just manually open the word doc later on to check?

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: RunTIme Error 4248

    Sorry I don't know what you mean.

    For the second code you posted Word has to be open, otherrwise there's nothing for GetObject to get.

  16. #16
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: RunTIme Error 4248

    sorry to confuse you.
    In your previous answer, you said "I'd probably go for Word not actually being open when it runs.". I thought if I want to, I can let excel paste into word without actually opening it. like a background thing that is processing. And I also thought, then I can just open the word doc later on to see if it has really pasted on.
    But the code is already working. together with the rows being adjusted based on cell value.
    Really nice...
    I envy your coding skills. Wish I could learn that too.
    Thanks really from the bottom of my heart. Save another tons of work in my job.

    Jhun here...

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: RunTIme Error 4248

    Jhun

    No problem.

  18. #18
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: RunTIme Error 4248

    Norie,
    may i have a follow up question.
    on this code
    Please Login or Register  to view this content.
    I only have F20 as my criteria.
    What I have either F20 or F47. If F20 has value either 0,1,2,3,4 then it will do as above.
    How do I edit such that if F20 is blank and the populated cell is F47 with either 0,1,2,3,4 also. it will also do as above. This time using different rows.

    I just edited the above code. It's just the nested if that I can't figure out.

    here is the code I am trying.

    Please Login or Register  to view this content.
    I can't get the other IF to work. It's just always the first if that copies to word.

    Please help again.

    Thanks

  19. #19
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: RunTIme Error 4248

    Try this.
    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    02-20-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: RunTIme Error 4248

    wow that was fast.
    I also did edit your previous code into this.

    Please Login or Register  to view this content.
    it also worked.

    this is finally solved Sir

    Thanks Thanks... For everyone to see...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1